Grep to find files... but locks up when none found?


I’m using the following command to get a collection of files, so we can get a dev instance running of the live site. Now, this is what I use:

perl -p -i -e "s|paypal\|paypal\|g" `grep -rl '' .`

That works well - APART from when no instances of can be found. In that case, it just sits there indefinitely.If you just run the command outside of the backticks, then it runs through fine:

grep -rl '' .

but as soon as you put the other command in front of it (and grab the files via the `` section), it just locks up if nothing can be found.

So, my question is - can we run this kinda of command to search+replace - but have it not lock up if no instances are found? :smile:



I don’t know that much about *nix… but, what if you opened another process and did the search in that? That way, if it locks up, you can kill it from your original process.



I finally realised my question was a bit stupid =) Seeing as I’m doing a rsync from the live site - the file that I would expect to match, will ALWAYS be a match - as rsync will see they are different, and pull the other one over again (ready for the grep to run on it)

Doh! :relaxed:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.