Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
    
Did you look into sed? –  Bernhard Apr 25 '13 at 20:08
add comment

2 Answers 2

up vote 1 down vote accepted
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.

share|improve this answer
add comment

With GNU find and sed you could:

find . -type f -print0 | xargs -0 sed -i '/^FIND$/d'
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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