• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Delete lines using sed

December 1, 2021

How to delete a line containing a pattern using sed.

Contents of test.txt.

$ cat test.txt
one
two
three

$ cat test.txt one two three

Delete a line matching the string “one.”

sed -i '/one/d' test.txt

sed -i '/one/d' test.txt

Display test.txt

$ cat test.txt
two
three

$ cat test.txt two three

Filed Under: Linux Tagged With: delete, line, matching, remove, sed

Search This Website

Subscribe Via Email

  • Home
  • About
  • Archives

Copyright © 2023