Skip to content

Instantly share code, notes, and snippets.

@snickerjp
Created February 2, 2012 11:05
Show Gist options
  • Save snickerjp/1722914 to your computer and use it in GitHub Desktop.
Save snickerjp/1722914 to your computer and use it in GitHub Desktop.
Perlで置換
cat /etc/nagios/nrpe.cfg.`date '+%Y%m%d'` |perl -e 'foreach(<>){ if(!/^#/ && /check_disk/){ s/check_disk -w \$ARG1\$ -c \$ARG2\$/check_disk -w \$ARG1\$ -c \$ARG2\$ -W \$ARG1\$ -K \$ARG2\$/; } print;}' > /etc/nagios/nrpe.cfg
cat /etc/nagios/nrpe.cfg.`date '+%Y%m%d'` |perl -e 'foreach(<>){ if(!/^#/ && /check_disk/){ s/check_disk\s+-w \$ARG1\$ -c \$ARG2\$/check_disk -w \$ARG1\$ -c \$ARG2\$ -W \$ARG1\$ -K \$ARG2\$/; } print;}' > /etc/nagios/nrpe.cfg
sed -e 's/check_disk -w \$ARG1\$ -c \$ARG2\$/check_disk -w $ARG1$ -c $ARG2$ -W $ARG1$ -K $ARG2$/' \
/etc/nagios/nrpe.cfg.`date '+%Y%m%d'` > /etc/nagios/nrpe.cfg
cp -p /etc/nagios/nrpe.cfg /etc/nagios/nrpe.cfg.`date '+%Y%m%d'`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment