For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > March 2004 > spaces in filenames using find | xargs perl -ne '<script>'









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author spaces in filenames using find | xargs perl -ne '<script>'
Isao Yagi

2004-03-26, 11:14 pm

On Linux and Mac OS X, I'm doing something like this to print a regex
substutution of matching lines in a batch of files:

find . -name 'somefile' | xargs perl -ne 'print if
s/search/replace/'

Problem is spaces appearing in the output of "find" cause errors.

I tried

find . -name 'somefile' -printf '"%p"\n' | xargs --max-args=1 perl
-ne 'print if s/search/replace/'

.... and other variations, but no luck, perl sees the file paths
containing spaces as seperate arguments.

Any suggestions?

Thanks,

Isao
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com