[linux] How to add lines to end of file on Linux

I want to add the following 2 lines:

VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 1600x1200"

to the end of the file vncservers found at the directory /etc/sysconfig/.

How can I do this?

This question is related to linux shell

The answer is


The easiest way is to redirect the output of the echo by >>:

echo 'VNCSERVERS="1:root"' >> /etc/sysconfig/configfile
echo 'VNCSERVERARGS[1]="-geometry 1600x1200"' >> /etc/sysconfig/configfile