I\'m writing a small shell script that needs to reverse the lines of a text file. Is there a standard filter command to do this sort of thing?
My specific applicatio
In this case, just use --reverse
:
$ git log --reverse --pretty=oneline work...master | grep -v DEBUG: | cut -d' ' -f1
: "@(#)$Id: reverse.sh,v 1.2 1997/06/02 21:45:00 johnl Exp $"
#
# Reverse the order of the lines in each file
awk ' { printf("%d:%s\n", NR, $0);}' $* |
sort -t: +0nr -1 |
sed 's/^[0-9][0-9]*://'
Works like a charm for me...
awk '{a[i++]=$0}END{for(;i-->0;)print a[i]}'
More faster than sed
and compatible for embed devices like openwrt.