Pete Pete - 4 months ago 7
Bash Question

Delete all lines containing a caret (^)

I tried

sed -i '/^/d' myfile
and it deleted the entire file. How to avoid this? I want to remove all lines with
^
in it.

Answer
sed -i '/\^/d' myfile

You need to escape the ^ special character.

Comments