0

I want to delete all lines containing string "abcfk" from all the .xml files in current directory tree. I tried find . -name "*.xml" | xargs sed -i 's/abcfk//g' but with this i can only replace..but not deleted the line. Any suggestions?

1 Answer 1

2

You could do:

sed -i '/abcfk/d' $(find . -name "*.xml")

note that s/abcfk//g will leave empty lines, instead use /abcfg/d to delete lines with abcfg. Alternatively:

find . -name "*.xml" -exec sed -i '/abcfk/d' {} +
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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