Leaving with Nothing
Home
Tuesday, December 1, 2015
Removing a line from a file using a terminal or shell command
There are various ways of doing this, my favorite is sed(1)
# sed -i '/foo/d' bar.txt
which removes the line "in place".
You can also do this with grep(1) but you'll need a temporary file:
# grep -v foo bar.txt > tmp.txt
# mv tmp.txt bar.txt
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment