inverting a list
Can I use linux text utilities to invert the lines of a text file? Say that the lines of the file are 50. (1,2, ...50) How can I change the order the of lines so that line 1 is now line 50?
Thanks,
Matthew Stapleton
============================
To dare is to lose one's footing momentarily. Not to dare is to lose oneself. -SK
============================
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Quoted 5 lines · Matthew Stapleton
Can I use linux text utilities to invert the lines of a text file? Say that the lines of the file are 50. (1,2, ...50) How can I change the order the of lines so that line 1 is now line 50?
Here's one off the top of my head. I'm sure
that somebody can come up with a better one.
---------------------------
#!/bin/bash
i=cat $1|wc -l
until [ $i = 0 ]
do head -n $i $1|tail -n 1
let i=i-1
done
---------------------------
Cheers,
Steven
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Quoted 20 lines · On Sun, 21 Jul 2002 [email protected] wrote:
Quoted 5 lines · Matthew Stapleton
Can I use linux text utilities to invert the lines of a text file? Say that the lines of the file are 50. (1,2, ...50) How can I change the order the of lines so that line 1 is now line 50?
Here's one off the top of my head. I'm sure
that somebody can come up with a better one.
---------------------------
#!/bin/bash
i=cat $1|wc -l
until [ $i = 0 ]
do head -n $i $1|tail -n 1
let i=i-1
done
---------------------------
Quoted 2 lines
Cheers,
Steven
If I understand the question, the answer is exactly, "tac".
Lawson
---oops---
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs