> -----Original Message----- > From: Kleiner Hampel > Sent: Sunday, March 16, 2003 10:41 AM > Subject: Re: shell script - expert question > > > Hi, > > now it works, but because of the '*'. > > now i want to remove the leading abc from all files in my directory. > i tried this: > > for i in *; do mv $i `echo $i | sed s/abc//`; done > > but it doesn't do that. > i always get the error, that the last arguement must be a directory! > I guess, the reason are the white spaces in the names. > perhaps the expression `echo $i | sed s/abc//` also have to > be set in '' or so, but it doesn't work this way. > > please help
Single quotes ' are treated literally by the shell interpreter. i.e. no filename expansion. With double quotes, your variables are expanded prior to being used. So... for i in * ; do mv "$i" `echo "$i" | sed -e 's/abc//'` done Note: Your example has not dealt with filenames that do NOT contain spaces. Steve Cowles -- redhat-list mailing list unsubscribe mailto:[EMAIL PROTECTED] https://listman.redhat.com/mailman/listinfo/redhat-list