I'm trying to retrieve the first and last row of awk command, but I'm not able to. Where I'm making mistakes.
egrep 'updateAll|update-mgr|Startup REX|configd.*UnitProperty updated' $LOG | \ awk 'NR == 1{print $1" "$2" "$3} NR == $#{print $1" "$2" "$3}' awk: cmd. line:2: NR == 1{print $1" "$2" "$3} NR == $#{print $1" "$2" "$3} awk: cmd. line:2: ^ syntax error I expect first row and last row form the output of grep command.
$#has no meaning in awk ... and if it understood the bashism it still wouldn't do what you want.