Software

Delete lines containing a specific string with sed

The following command makes sed delete every lines containing the matching pattern from the file named foo. If this file is important, we make sure to back it up first!

$ sed -i '/pattern/d' /path/to/foo

The -i flag (GNU version only) edit the file in-place. For non-GNU version, we can redirect the output with >.

$ sed '/pattern/d' /path/to/foo > /path/to/foo

Back


Comments

No comment yet.

A remark, a suggestion? Do not hesitate to express yourself below. Just be courteous and polite, please.

If this field is left blank, you will appear as Anonymous.