THE UNIX PROGRAMMING ENVIRONMENT by Kernighan and Pike to the rescue!
According to Appendix A, to reverse lines,
g/^/m0
Or, better yet, in rc:
awk '
{ x[NR] = $0}
END {
for (i = NR; i >= 1; i--)
print x[i]
}'
On Dec 23, 2007, at 11:17 PM, Anthony Martin wrote:
I was feeling obscene and decided to test out stupid
commands in sam and acme. Here's something I didn't
expect.
Sam:
, x g/^/m. no change to file
Acme (Edit):
, x g/^/m. aborts in /sys/src/cmd/acme/ecmd.c:/^move
It aborts because "move overlaps itself" but the
question I have is, should it work like sam and
do *visually* nothing at all?
Anthony
P.S.
This came about because I was trying to find a way to
move lines matching a certain pattern to the beginning
of a file (like g/pattern/m0 in ed). Is there a nice
way to do this in sam?
Something that works like the ed command but leaves the
lines in original order, not reversed, would be even
better.
--
I spent a night with a blow-up girl and some LSD. -Freeheat