Can someone please explain below code.
$LIST|awk ' /^$/ { next }
substr($0,1,4)=="Exiting" { mk = 1; next }
mk==1 { print $3,$7,$10,$14; exit }
Cheers,
gehlnar
Can someone please explain below code.
$LIST|awk ' /^$/ { next }
substr($0,1,4)=="Exiting" { mk = 1; next }
mk==1 { print $3,$7,$10,$14; exit }
Cheers,
gehlnar
Assuming '$LIST' is some kind of a file....
This code will not work as quoted - I took the liberty of modifying it and commenting
awk '
# skip eny "empty" lines
/^$/ { next }
# If the first 4 characters are "Exiting", set "mk" to 1 and proceed to the next record/line
# This condition will never be true as "Exiting" contains 7 chars
substr($0,1,4)=="Exiting" { mk = 1; next }
# If "mk" is 1, print the 3rd, 7th, 10th and the 14th field from the current record/line and exit -
# the rest of the lines will not be processed
mk==1 { print $3,$7,$10,$14; exit }
' $LIST
In essense, the objective is:
It cannot be a file; it must be a command that prints information on stdout.
It cannot be a command - it would have been a '$(LIST)' for that.
The name of a 'variable' is suspicious as well.
The OP will have to chime in.
Yep, you're right - I retract my statement.
Hi cfajohnson/ vgersh99
Thanks for the explaination.
Cheers,
gehlnar