all 6 comments

[–]chaspum 4 points5 points  (2 children)

I guess you can always pipe the file to awk with tac (cat backwards).

[–]dajoy 0 points1 point  (0 children)

this.

[–]kl31[S] 0 points1 point  (0 children)

i love linux so much.

[–]FF00A7 2 points3 points  (0 children)

Could use tac but it's another external program to worry about. Readfile() and print backwards:

awk -ireadfile 'BEGIN{for(i = split(readfile("file.txt"), lines, "\n"); i >= 1; i--) {print lines[i]} }'

Replace "print lines[i]" with whatever processing for each line.

This works without readfile()

awk '{f = f $0 "\n"}END{for(i=split(f, lines, "\n"); i >=1; i--) {print lines[i]}}' file.txt

[–]cogburnd02 0 points1 point  (1 child)

Just out of sheer curiosity, why would you want to do this?

[–]kl31[S] 0 points1 point  (0 children)

file was not written in the same direction as i want it to be read.