PDA

View Full Version : command line recursive find and replace - how to excape special chars in file names?


Jeff
01-13-2007, 03:36 AM
For a few years I've been happily using this to find and replace text from the command line
find * -name '*.html' | xargs perl -pi -e "s/2002-2006/2002-2007/sg;"
thanks to Arthur http://aota.net/forums/showthread.php?postid=56104#post56104

However I encountered a snag tonight - if a file name includes a ' (e.g. the_year's_best.html) I get an error:

xargs: unmatched single quote

How do I handle this?

hobbes
01-13-2007, 09:07 AM
Check into the use of find ... -print0 | xargs -0 ...