How To Append Lines To File If They Do Not Exist
1FILE=/etc/samba/smb.conf
2
3LINES=$(cat <<EOF
4[scan]
5Comment = Scans
6Path = /var/scan
7Browseable = yes
8Writeable = Yes
9only guest = no
10guest ok = no
11create mask = 0777
12directory mask = 0777
13Public = no
14EOF
15)
16
17grep -q "${LINES}" ${FILE} && echo "Nothing to do" || \
18 echo "${LINES}" | tee -a ${FILE}