user-avatar
Today is Thursday
May 2, 2024

Tag: sed

November 9, 2009

Using sed

by viggy — Categories: tech — Tags: , , Leave a comment

How to use sed command to remove lines from a file which match a particular pattern.

sed ‘//d’ file-name > tmp

This command will delete all the lines from the file which match the pattern and then store the contents in the ‘tmp’ file.

How to use sed command to substitute strings which match a pattern and then replace it with another string?

sed -e ‘s///’

This command is to match a string and replace it with another string. The new contents of the will be stored in

How to use a pattern matched in sed command also in the replaced string?

Use & to substitute the matched string.