|
How to print specific lines with awk
Hi!
How can I print out a specific range of rows, like "cat file | awk NR==5,NR==9", but in the END-statement?
I have a small awk-script that finds specific rows in a file and saves the line number in an array, like this:
awk '
BEGIN { count=0}
/ZZZZ/ {
list[count]=NR
counter++
}
END {
print "Total of:" count " rows."
for (i in list) {
print "Row: " list[i] ## Here, also print the actual row with linenr:list[i].
}
}
' infile.txt
Any help would be much appreciated.
//Bugenhagen
|