Re: tac replacement
- From: Ed Morton <morton@xxxxxxxxxxxxxx>
- Date: Mon, 26 Nov 2007 16:12:21 -0600
On 11/26/2007 3:16 PM, Jürgen Kahrs wrote:
yiyu.jgl@xxxxxxxxx schrieb:
I need to process the end of a file before the beginning. I have seen
some threads where a tac | awk ... | tac solution is proposed, but
there is always the problem of not having tac in your system.
If you have a Unix sort command, then try this:
awk '{print NR, $0}' data_file.txt | sort -n -r | awk '{$1=""; print $0}'
That'll add a leading space and compress the rest of the spacing between fields.
If you really wanted to do that in awk|sort|awk, you'd do:
awk '{print NR, $0}' data_file.txt | sort -n -r | awk 'sub(/[[:digit:]]+ /,"")'
There are of course better UNIX tac-alternatives but that'd be best discussed in
comp.unix.shell....
Ed.
.
- References:
- tac replacement
- From: yiyu.jgl@xxxxxxxxx
- Re: tac replacement
- From: Jürgen Kahrs
- tac replacement
- Prev by Date: Re: awk question
- Next by Date: Re: tac replacement
- Previous by thread: Re: tac replacement
- Next by thread: Re: tac replacement
- Index(es):
Relevant Pages
|