ex4_rev.awk (358B)
1 #!/usr/bin/env -S awk -f 2 3 BEGIN { 4 # Quit if we don't have an input file. 5 if (ARGC < 2) { 6 print "usage: ex4_rev.awk file"; 7 exit 1; 8 } 9 } 10 11 { 12 # Add all lines to an array. 13 ln[NR] = $0; 14 } 15 16 END { 17 # Print them in reverse. 18 for (i = NR; i >= 1; i--) 19 print ln[i]; 20 }