[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Shell Scripting Question



Apparently, on Mon, Nov 05, 2001 at 09:04:38PM -0500, 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
> 
> 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 ...
> 
> thanks much for any info you might provide
> 

The IFS includes a space by default so, for example, "some file.txt" would
cause cat to look for 
/some/dir/some
/some/dir/file.txt
Set IFS to just new lines before running the for loop and you should
be fine

-- 
Tim Moss
debian@to11.net



Reply to: