msgbartop
MAC OS X, Linux, Windows and other IT Tips and Tricks
msgbarbottom

14 Feb 10 Replacing the missing ‘tac’ command in MAC OS X

After looking into Fink Command and Porticus I could not find the GNU command ‘tac’ for writing bash scripts.
So I found these replacements which works well from the following link (Thanks guys :-))
//trac.osgeo.org/grass/ticket/181

Normal use of tac: .....| tac |.......

Replacement Nr. 1
.....| awk '{print NR,$0}' | sort -nr | sed 's/^[0-9]* //' | .......
Replacement Nr. 2
tac () {
awk '1 { last = NR; line[last] = $0; } END { for (i = last; i > 0; i--) { print line[i]; } }'
}

Reader's Comments

  1.    

    Replacement Nr. 3:tail -r

    Reply to this comment

Leave a Reply to Donald Lam Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: