Re removing hyphens from filenames

Andreas Plesner Jacobsen apj at mutt.dk
Thu Jul 12 13:49:05 BST 2007


On Thu, Jul 12, 2007 at 02:28:52PM +0200, Abigail wrote:

> > >for f in `find . -name '*-*'`; do mv $f `echo $f | tr -d -`; done
> > 
> > I generally avoid the use of `for' in operations such as this - you
> > never know when people have created files with spaces in the name.
> 
> In that case:
> 
> IFS=
> for f in `find . -name '*-*'`; do mv $f `echo $f | tr -d -`; done

I'd rather do a:
find -print0 . <find-pattern> | xargs -0 <file manipulation commands>

That solves any problems wrt shell limits on parameter count and special
characters.

-- 
Andreas


More information about the london.pm mailing list