Here's an easy way to do it, using cat
.
% cat - >> testf
one
two
three
four
You terminate your input with the CTRL-D .
This takes interactive input from cat
(i.e., whatever you type in), and appends it to the existing file testf
.
testf
(with two original lines intact) will now look like this:
original line 1
original line 2
one
two
three
four
As other answers have illustrated, you will need special syntax when editing files which you don't have write permission on. I find it easier to just switch to the root user for this, i.e., sudo su
. But another easy method is to use tee
with the append flag set, and called with sudo
:
sudo tee -a >> config.conf