How would I use sed to delete all lines in a text file that contain a specific string?
How to delete from a text file, all lines that contain a specific string
in-placesedshelltext-parsing
Related Topic
- Shell command to sum integers, one per line
- Unix – How to reverse the order of lines in a file
- How to mkdir only if a directory does not already exist
- Bash – How to split a string on a delimiter in Bash
- Bash – How to count all the lines of code in a directory recursively
- Unix – Delete specific line number(s) from a text file using sed
- Linux – How to exclude a directory in find . command
- How to copy a folder from remote to local using scp
Best Answer
To remove the line and print the output to standard out:
To directly modify the file – does not work with BSD sed:
Same, but for BSD sed (Mac OS X and FreeBSD) – does not work with GNU sed:
To directly modify the file (and create a backup) – works with BSD and GNU sed: