How to add lines to end of file on Linux

LinuxShell

Linux Problem Overview


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?

Linux Solutions


Solution 1 - Linux

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAntony WestView Question on Stackoverflow
Solution 1 - Linuxuser897079View Answer on Stackoverflow