Unix/Linux

파일 수정 자동화 sed

steloflute 2013. 6. 27. 23:30

sed를 이용한 파일 수정 자동화

 

echo $TMOUT; if [ "x$TMOUT" != "x300" ]; then cp /etc/profile /etc/profile.20130627; sed s/^.*TMOUT=600$/TMOUT=300/ /etc/profile.20130627 > /etc/profile; diff /etc/profile /etc/profile.20130627; else echo OK; fi;

 

 

cp /etc/inetd.conf /etc/inetd.conf.20130628; sed -e 's_^ntalk   dgram   udp     wait    root    /usr/sbin/talkd         talkd_#ntalk   dgram   udp     wait    root    /usr/sbin/talkd         talkd_' -e 's_^daytime.*stream.*_#daytime        stream  tcp     nowait  root    internal_' -e 's_^time.*stream.*_#time   stream  tcp     nowait  root    internal_' -e 's_^daytime.*dgram.*_#daytime        dgram   udp     wait    root    internal_' -e 's_^time.*dgram.*_#time   dgram   udp     wait    root    internal_' -e 's_^dtspcd.*_#dtspcd stream  tcp     nowait  root    /usr/dt/bin/dtspcd /usr/dt/bin/dtspcd_' /etc/inetd.conf.20130628 > /etc/inetd.conf; diff /etc/inetd.conf /etc/inetd.conf.20130628; refresh -s inetd; egrep 'talk|time|dtspcd' /etc/inetd.conf