All of lore.kernel.org
 help / color / mirror / Atom feed
* inverting a list
@ 2002-07-20 21:54 Matthew Stapleton
  2002-07-21 12:31 ` ichi
  0 siblings, 1 reply; 5+ messages in thread
From: Matthew Stapleton @ 2002-07-20 21:54 UTC (permalink / raw)
  To: linux-newbie

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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: inverting a list
@ 2002-07-21  3:30 Matthew Stapleton
  0 siblings, 0 replies; 5+ messages in thread
From: Matthew Stapleton @ 2002-07-21  3:30 UTC (permalink / raw)
  To: ichi; +Cc: linux-newbie

It worked ...much 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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: inverting a list
  2002-07-21 12:31 ` ichi
@ 2002-07-21  3:37   ` lawson_whitney
  0 siblings, 0 replies; 5+ messages in thread
From: lawson_whitney @ 2002-07-21  3:37 UTC (permalink / raw)
  To: ichi; +Cc: matthewstapleton, linux-newbie

On Sun, 21 Jul 2002 ichi@ihug.co.nz wrote:

> st:	linux-newbie@vger.kernel.org
>
> Matthew Stapleton wrote:
> >
> > 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

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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: inverting a list
@ 2002-07-21  3:53 Matthew Stapleton
  0 siblings, 0 replies; 5+ messages in thread
From: Matthew Stapleton @ 2002-07-21  3:53 UTC (permalink / raw)
  To: lawson_whitney; +Cc: ichi, linux-newbie

Yes I knew there was an app that did exactly what I wanted...out of the
hundreds linux provides I could not remember.. Thanks -MS


On Sat, 20 Jul 2002 23:37:57 -0400 (EDT) lawson_whitney@juno.com writes:
> On Sun, 21 Jul 2002 ichi@ihug.co.nz wrote:
> 
> > st:        linux-newbie@vger.kernel.org
> >
> > Matthew Stapleton wrote:
> > >
> > > 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
> 
> If I understand the question, the answer is exactly, "tac".
> 
> Lawson
> ---oops---
> 
> 
> 


Matthew Stapleton
============================
People demand freedom of speech as a compensation for the freedom of
thought which they seldom use.  -SK
============================
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: inverting a list
  2002-07-20 21:54 inverting a list Matthew Stapleton
@ 2002-07-21 12:31 ` ichi
  2002-07-21  3:37   ` lawson_whitney
  0 siblings, 1 reply; 5+ messages in thread
From: ichi @ 2002-07-21 12:31 UTC (permalink / raw)
  To: Matthew Stapleton; +Cc: linux-newbie

Matthew Stapleton wrote:
> 
> 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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-07-21 12:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-07-20 21:54 inverting a list Matthew Stapleton
2002-07-21 12:31 ` ichi
2002-07-21  3:37   ` lawson_whitney
  -- strict thread matches above, loose matches on Subject: below --
2002-07-21  3:30 Matthew Stapleton
2002-07-21  3:53 Matthew Stapleton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.