Linux Newbie help
 help / color / mirror / Atom feed
From: ichi@ihug.co.nz
To: Matthew Stapleton <matthewstapleton@juno.com>
Cc: linux-newbie@vger.kernel.org
Subject: Re: inverting a list
Date: Sun, 21 Jul 2002 12:31:32 +0000	[thread overview]
Message-ID: <3D3AA9A4.AD7C28E@ihug.co.nz> (raw)
In-Reply-To: 20020720.175417.-315329.2.matthewstapleton@juno.com

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

  reply	other threads:[~2002-07-21 12:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-20 21:54 inverting a list Matthew Stapleton
2002-07-21 12:31 ` ichi [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3D3AA9A4.AD7C28E@ihug.co.nz \
    --to=ichi@ihug.co.nz \
    --cc=linux-newbie@vger.kernel.org \
    --cc=matthewstapleton@juno.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox