Delate



Delete messages from .maildir/cur/ with custom subject [sub: lfd on mail]# egrep -R -l "lfd on mail" | xargs rm -f




find a word in a file and delete the file


sed -i.bak '/NOT FOR RELEASE\./d' ./info.txt # will delete lines containing "NOT FOR RELEASE."


Remove all empty linesRemove lines containing a stringRemove lines starting with a word


Shell Programming and Scripting:  To find a word in a file and delete the file
find . -type f -exec grep -H -R "word" {} \; | xargs rm -rf\find . -type f -exec grep -l "word" {} \; | xargs rm -rf
find . -type f -exec grep -w "word" {} \; -print | grep "^./" | xargs rm -rffind . -type f -exec grep -w "word" {} \; -print | grep "^./" | xargs rm -rf
-----------------------------Deleting lines above a certain linesed '1,/{{word}}/d' myFile--------------------How can I delete a line from a file when the line contains a specific string123,aaa,bbb,888,8881124,bbb,ccc,999,8881125,ccc,ddd,888,8883I have to delete the line containing 888.Using sed,
sed '/888/d' filenameYou can use, -i option to edit file in-place like,
sed -i.bak '/888/d' filenameNote : .bak will keep backup of original file.--------------------How to remove lines from the text file containing specific words through terminal?grep -vwE "(cat|rat)" sourcefile > destinationfilesed -i "/\b\(cat\|rat\)\b/d" filename

Using awk to exclude lines containing specific words:$ awk '!/\<(cat|rat)\>/{print $0}' ./input.txt
Delete lines from all files that match the matchgrep -rl 'text_to_search' . | xargs sed -i '/text_to_search/d'-----------------------Bash script to delete a line if a particular string is found any where in the line$ sed -e "/fast/d" filename
$ sed -e "/fast/d" sample.txt > tmp $ mv tmp sample.txt -------------------------Using sed to delete a whole line if it contains only specific numberI have a txt file
123456789456123456I want to delete specific characters from the file i.e (123). I tried with
$ sed -i '/123/d' dummy.sh$ vi dumm.txt456789456In the below command when I run both the words (123 and 123456) are getting deleted but I need to delete only 123 from the file
$ sed -i 's/123//g' dummy.sh$ vi dumm.txt456789456456
sed -i '/^123$/d' dummy.sh      #delete whole linesed -i 's/^123$//' dummy.sh     #replace with empty line------------------------delete line containing a specific string in shellsed -i "/\bexample\b/d" myfile-------------------------How to delete from a text file, all lines that contain a specific string?sed -i '/pattern to match/d' ./infileawk '!/pattern/' file > temp && mv temp file
sed -i '/pattern/d' filename      orgrep -v "pattern" filename > filename2; mv filename2 filename--------------------------Delete all lines containing a string from a file in Bashsed -i.bak '/NOT FOR RELEASE/d' ./info.txtsed -i.bak '/NOT FOR RELEASE\./d' ./info.txt # will delete lines containing "NOT FOR RELEASE."----------------How to delete from a text file, all lines that contain a specific string?sed -i '/pattern to match/d' ./infile---------------------------Remove lines starting with a wordsed -i '/^word/d' filename