Bash tips & tricks

Jun 18, 2019 17:19 · 45 words · 1 minute read bash tips

Bash variable with the content of a file

NTPFILECONTENT=$(cat /etc/chrony.conf)

This will store the ‘\n’ characters as well.

Display bash variable with the content of a file

echo "${NTPFILECONTENT}"

Beware the quotes

Append content to a bash variable with a new line

NTPFILECONTENT="${NTPFILECONTENT}"$'\n'"pool ${ntp} iburst"
tweet Share