I want to use awk for printing a match of some pattern, only if it is the last line of the file before some constant text.
For example, i want to print the value of "c" only if it is the last line before some constant text:
cat file.txt:
a=1
b=2
c=3
...constant text...
print 3.
cat file.txt:
a=1
c=3
b=2
...constant text...
do not print anything.
How do I do that..? How can awk know if it's the last number of the file?
awk -F'=' 'END{if ($1=="c") print $2}
'/...constant text.../{if (Prev[$1]=="c") print Prev[$2]}{split($0,Prev)}'
awk -F'=' '/...constant text.../{if (Prev[1]=="c") print Prev[2]}{split($0,Prev)}'
?