How to delete a line containing a pattern using sed.
Contents of test.txt.
$ cat test.txt
one
two
three |
Delete a line matching the string “one.”
sed -i '/one/d' test.txt |
Display test.txt
$ cat test.txt
two
three |
cloud engineer
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
Here’s how to modify a line in a file using sed.
sed -i 's/replace me.*/with this text/' /path/to/a/file.txt |
sed -i 's/replace me.*/with this text/' /path/to/a/file.txt
Here’s a simple sed command to replace multiple spaces into a comma delimited file.
sample.txt
one two three four |
one two three four
The sed command.
sed 's/ \+ /,/g' sample.txt > sample2.txt |
sed 's/ \+ /,/g' sample.txt > sample2.txt
sample2.txt
one,two three,four |
one,two three,four