Operating System - HP-UX
1753826 Members
8448 Online
108805 Solutions
New Discussion

Re: change 5th line after a pattern - AWK

 
SOLVED
Go to solution
user57
Occasional Advisor

Re: change 5th line after a pattern - AWK

Thank you JRF for the excellent response - spot on! I thought of a relatively straight-forward approach to the problem. Changing the desired value and preserving all others:

awk 'BEGIN { FS="\n"; RS=""; OFS="\n"; ORS="\n\n" }

$0 !~/^\/usr\/sbin\/bootpd:/ { print }

$1 ~/^\/usr\/sbin\/bootpd:/ {
$6=" mode = r-xr-xr-x"
print
} ' file


Thank you also Hein for the most recent post. I haven't actually tested it as I was working on an alternative solution and reviewing JRF's perl approach.
user57
Occasional Advisor

Re: change 5th line after a pattern - AWK

Just reviewed your post Hein - a neat solution.

Thanks