Input file text.txt:
foo()
{
}
buz()
{
}
Awk script.awk:
BEGIN {
RS = "\n\n+";
FS = "\n";
}
/[a-z]+\(\)\n/ {print "FUNCTION: " $1;}
{print "NOT FOUND: " $0;}
Running script:
awk -f script.awk text.txt
gives:
NOT FOUND: foo()
{
}
NOT FOUND: buz()
{
}
But I’ve expected to match both functions WITH newlines. How to do this?
You can try this:
If you want to verify that there is nothing after the () you can do this:
$1~/[a-z]+()$/ {print “FUNCTION: ” $1;}
I don’t know why newline isn’t matched. Maybe someone would explain it.