Last Updated: February 25, 2016
·
672
· andrewjsledge

Run sed on the last X lines of a file

Runs an inline sed to comment out the last seven lines of a file

sed -i "$(($(cat /etc/nagios/objects/commands.cfg | wc -l) - 7)),$(cat /etc/nagios/objects/commands.cfg | wc -l)s/^/#/" /etc/nagios/objects/commands.cfg