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

Re: Shell Expansion in Bourne Shell Script Question



On Wednesday 28 July 2010 13:05:22 Karl Vogel wrote:
> >> On 28.07.2010 14:42, Jochen Schulz wrote:
> J> I think you meant to write
> J>     for MAGFILE in `ls $MAGDIR/*.[Zz][Ii][Pp]`
> J> Another hint: you don't need 'ls' for your case at all.
> 
>    I'd recommend keeping the "ls".

Then, you would be wrong.  Doing the splitting on the output of ls causes IFS 
characters in file names to be handled incorrectly:

bss@dellbuntu:/tmp% touch 'file with spaces'
bss@dellbuntu:/tmp% for f in `ls -d *`; do echo file; done | wc -l
9
bss@dellbuntu:/tmp% for f in *; do echo file; done | wc -l 
7
-- 
Boyd Stephen Smith Jr.           	 ,= ,-_-. =.
bss@iguanasuicide.net            	((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy 	 `-'(. .)`-'
http://iguanasuicide.net/        	     \_/

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: