Script command to Update config file and avoid duplicate entries in Shell

There are times when you have multiple servers to edit files like /etc/fstab but you want to make sure you don’t have duplicate entries in that file. All us Unix admins know what that means.

LINE='tools:/mnt/spool      /mnt/spool    nfs     intr    0       0'
grep "$LINE" /etc/fstab >/dev/null  || echo $LINE >> /etc/fstab


View all posts by

Leave a Reply

Your email address will not be published. Required fields are marked *