Jimmy
Jimmy

Reputation: 12487

Shell - Creating text file which appends content - Using cat

I have this code for example:

rm /etc/rc.local
cat <<EOF >/etc/rc.local
#!/bin/sh -e
apt-get update && apt-get -y install git-core
EOF

Is there a way instead of having it so I don't need to delete the original rc.local and make a new one, but instead I can use pretty much the same code but append this content to the bottom of the rc.local file, rather than recreating it?

Upvotes: 2

Views: 798

Answers (1)

Gilles Qu&#233;not
Gilles Qu&#233;not

Reputation: 185025

Try this :

cat <<EOF >>/etc/rc.local

apt-get update && apt-get -y install git-core
EOF

Or simply :

echo 'apt-get update && apt-get -y install git-core' >> /etc/rc.local

Upvotes: 3

Related Questions