On Tue, Jul 03, 2001 at 02:33:19PM +1000, Jeff Waugh wrote:
> <quote who="Alister Waller">
>
> > for i in `ls *.TXT`
> > do
> > cat $i >> newfilename
> > mv $i /tmp
> > done
>
> Why cat? cp $i newfilename would do pretty well.
he's got a >> there, not a >, so cp $i newfilename isn't the same :).
a better solution would probably be:
for i in *.TXT; do
cat $i >> newfilename && mv $i /tmp
done
(1) you can just do *.TXT; no need for `ls *.TXT`.
(2) the && checks the error code returned by cat, so that the mv is only
done if there was no errors.
> > Now, if there are no *.TXT files then I get an error sent back to the owner
> > of the crontab file.
>
> "2> /dev/null"
ie
( for i in *.TXT; do cat $i >> newfile && mv $i /tmp; done ) 2> /dev/null
to make Jeff's last comment completely unambigious :)
(can you replace the () with {} for that loop? not sure if you can
redirect the entire loop to /dev/null if you don't run a subshell.)
--
#ozone/algorithm <[EMAIL PROTECTED]> - trust.in.love.to.save
--
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug