"James R. Van Zandt" <[EMAIL PROTECTED]> writes:

> I would appreciate some pointers on this.  For example, I often use
> this idiom:
> 
>      for x in *.txt; do sed 's/which/that/' $x >foo && mv foo $x; done
> 
> Which would of course break if any filename had spaces.
> 
> I know about the -exec and -print0 options of find, but AFAIK -exec
> only works with a single command and -print0 only works with a few
> programs that can accept null-delimited filenames.  Do you have
> something else in mind?

Try enclosing variable referenced in double-quotes:

  for x in *.txt; do sed 's/which/that/' "$x" >foo && mv foo "$x"; done


Welcome to shell-script hell,

--kevin

PS:  Tip: Shy away from $* and instead use "${@}" in shell-scripts.

-- 
Kevin D. Clark (cetaceannetworks.com!kclark)  |   Will hack Perl for
Cetacean Networks, Inc.                       |  fine food, good beer,
Portsmouth, N.H. (USA)                        |       or fun.
alumni.unh.edu!kdc (PGP Key Available)        |


**********************************************************
To unsubscribe from this list, send mail to
[EMAIL PROTECTED] with the following text in the
*body* (*not* the subject line) of the letter:
unsubscribe gnhlug
**********************************************************

Reply via email to