On Fri, 2003-01-10 at 06:10, Stijn Hoop wrote:
> On Thu, Jan 09, 2003 at 01:51:08PM -0500, parv wrote:
> > in message <[EMAIL PROTECTED]>,
> > wrote Stijn Hoop thusly...
> > >
> > > On Fri, Jan 10, 2003 at 01:49:18AM +1030, Rob wrote:
> > > > > If you want to do it for all files in a directory:
> > > > >
> > > > > # for file in *; do mv "$file" `echo $file | sed -e 's/ /_/g'`; done
> >                                           ^     ^
> >                                           ^     ^
> > > > >
> > > > But if you do this, won't the spaces be mistaken for filename
> > > > separators?
> > > 
> > > No, he has quotes around his $file, and the `` part replaces
> > > spaces, so this should work.
> > 
> > notice that $file is not enclosed in the sub shell (in between 
> > ``) as an argument to echo.  if the $file happens to have end
> > blanks, they will be eaten up.  try...
> > 
> >   f=' p q r '; echo $( echo $f | sed 's/ /_/g' )
> > 
> > ...output /should/ have been '_p_q_r_', but is 'p_q_r'.
> 
> Hey, great, missed that one. I only considered the 'space not at end'
> case. Thanks.

My bad, forgot to include the quotes. But OTOH, people who put spaces at
the beginning and end of their filenames deserve everything they get
(besides, it worked for the original poster's test case :-)



The information contained in this email is confidential.
If you are not the intended recipient, you may not disclose or use the
information in this email in any way.
Dark Blue Sea does not guarantee the integrity of any emails or attached
files.
The views or opinions expressed are the author's own and may not reflect
the views or opinions of Dark Blue Sea.
Dark Blue Sea does not warrant that any attachments are free from
viruses or other defects.
You assume all liability for any loss, damage or other consequences
which may arise from opening or using the attachments.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message

Reply via email to