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

Re: for i in *



Hi Hans, 

Hans wrote:

> I still don't understand the proper syntax for this: I want to process
> multiple files, e.g. symlinking a bunch or converting graphics.
> 
> for i in *;do 'ln -s $i /home/newdir/$i';done
> 
> won't work.

Several folks have already suggested, that you just need to get rid of
the '' quotes.  However, if some files have spaces in their file name,
you actually do need quotes, like this.

	for i in *; do ln -s "$i" "/home/newdir/$i"; done

This makes sure that the filename $i and the new location
/home/newdir/$i is exactly one arguement each to the ln command and not
split on word boundaries.

Of course, some people argue, that spaces in filenames is a Bad
Thing(tm), but I fail to see why.

Cheers,
Viktor
-- 
Viktor Rosenfeld
WWW: http://www.informatik.hu-berlin.de/~rosenfel/



Reply to: