Re: Shell Scripting Question
Hi Sunny!
Sunny Dubey wrote:
> Hey,
>
> how come the followind doesn't seem to work ...
>
> for i in `ls -1 /some/dir` ; do
> cat /some/dir/"$i" >> /usr/fruits.txt
> done
>
because $i contains lines like:
drw-r--r-- 2 sunny sunny 12345 Oct 23 14:09 hello.c
which is very unlikely to be a filename.
I think you want:
for i in /some/dir/* ; do
cat $i >> /usr/fruits.txt
done
> cat just gives me the odd error of files not being found, however, I can't
> see why the files wouldn't be found ... hrrm ...
Files with spaces, tabs and colons in their names are evil anyway.
John P Foster
Reply to: