Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Jan 2004 18:32:25 -0500
From:      Charles Swiger <cswiger@mac.com>
To:        Xpression <admin@atenas.cult.cu>
Cc:        FreeBSD-questions <freebsd-questions@FreeBSD.ORG>
Subject:   Re: Script question...
Message-ID:  <94134190-4557-11D8-A7A0-003065ABFD92@mac.com>
In-Reply-To: <001601c3d960$696a5550$0901a8c0@bloodlust>
References:  <001601c3d960$696a5550$0901a8c0@bloodlust>

next in thread | previous in thread | raw e-mail | index | archive | help
On Jan 12, 2004, at 6:04 PM, Xpression wrote:
[ ...a question on how to change a shell script... ]

Try:

#! /bin/sh
path=/some/dir
if !([ -f $path/this.one ]); then
     touch $path/this.one
     for file in $path/file1 $path/file2 $path/file3; do
        echo "-----------------------------------------" >> 
$path/this.one
        echo "   $file" >> $path/this.one
        echo "-----------------------------------------" >> 
$path/this.one
        cat $file >> $path/this.one
     done
fi

Also note that using a local variable named $path is not a good idea, 
since $PATH is highly important.  :-)  $path and $PATH are seperate in 
/bin/sh, but many other shells automangle the colon-seperated $PATH 
into the word-list format used by $path, and vice-versa.

-- 
-Chuck



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?94134190-4557-11D8-A7A0-003065ABFD92>