I run the following command which comments out all lines that contain the text "dlclose"

grep -lIR "dlclose" . | grep -v ".svn" | xargs sed -i "s/.*dlclose.*/\/\/&/g"

However, sed claims that the piped files don't exist:

sed: can't read ./Utilities/src/DynLib.cpp: No such file or directory

This doesn't make any sense since grep was able to find and pipe the filename.

What is going on here? Is it piped in the wrong format?


Also, as a side note, I would like to merge the two greps, but I am forced to use grep 2.5.1 which doesn't have exclude-dir

link|improve this question
It works for me. Maybe adding "--verbose" or "-t" to the xargs switches to see exactly what xargs is trying to execute will help. – Mark Wagner Aug 11 '10 at 22:48
Works fine for me too so I do not know what else to suggest. – Richard Holloway Aug 11 '10 at 23:27
feedback

1 Answer

If the file is a symlink pointing to a non-existant file, that's the error you'll get.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.