Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert a sed 1 liner to an awk 1 liner 1

Status
Not open for further replies.

tumichaelf

IS-IT--Management
May 17, 2011
33
US
I have am trying to learn awk, and what I want to do is covert
Code:
sed -i 's/check_disk\ \-w\ 20\%/check_disk\ \-w\ 15\%/g' /var/tmp/nrpe.cfg
into an awk 1 liner similar to
Code:
awk '/^command\[check_disk\]=/&&!/-x \/boot/{$0=$0 " -x /boot"}1' /var/tmp/nrpe.cfg > /var/tmp/nrpe.cfg.new
(written by feherke ( for me in a separate post).

Thanks,

Michael
 
Like this ?
Code:
awk '{sub(/check_disk -w 20%/,"check_disk -w 15%");print}' /var/tmp/nrpe.cfg > /var/tmp/nrpe.cfg.new

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hey PHV,

Thanks a lot for this! Much appreciated.

Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top