1

I'm using:

grep -n -H -o -R -e textword .

List all file recursively under directory '.' with string 'textword' and show the file, line and only portion matching.

I need to remove lines that matched the text using a Linux command.

  • Did you look into sed? – Bernhard Apr 25 '13 at 20:08
1
find . -type f -exec sed -r -i "/textword/d" {} +

Remember that the search text is interpreted as a regexp by sed (with the -r option), so it might need escaping.

Use sed -i.backup to backup original files as <filename>.backup.

1

With GNU find and sed you could:

find . -type f -print0 | xargs -0 sed -i '/^FIND$/d'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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