Re: Script question...
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 ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Script question...
On Monday 12 January 2004 05:04 pm, Xpression wrote: > Hi list, I've making a script to write the content of three text files to > one file, but I want to separate each files by a delimiter like the name of > the file. > > This is the script: > > #! /bin/sh > path=/some/dir > if !([ -f $path/this.one ]); then > for file in $path/file1 $path/file2 $path/file3; do > cat $file >> $path/this.one > done > fi > > exit 0 > > By now the output is: > > Contents of file1 > Contents of file2 > Contents of file3 > > And I want to be like this: > --- > file1 > --- > Contents of file1 > --- > file2 > --- > Contents of file2 > --- > file3 > --- > Contents of file3 > > any suggestion ??? Thanks... I haven't tested it; but would this work: #! /bin/sh path=/some/dir if !([ -f $path/this.one ]); then for file in $path/file1 $path/file2 $path/file3; do echo '-' >> $path/this.one echo $file >> $path/this.one cat $file >> $path/this.one done fi exit 0 Andrew Gould ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Script question...
> Hi list, I've making a script to write the content of three text files > to one file, but I want to separate each files by a delimiter like the > name of the file. Maybe this little sh(1) script can do the job: # = begin.script = #! /bin/sh path=~/tmp files="file1 file2 file3" output_file=this.one cd ${path} && [ ! -f ${output_file} ] && \ for file in ${files} do echo >> ${output_file} echo ${file} >> ${final_file} echo >> ${output_file} cat ${file} >> ${final_file} done echo >> ${output_file} exit 0 # = end.script = -- -jpeg. ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"