Find the answer to your Linux question:
Results 1 to 6 of 6
I would like to find a commando that would enable me to exract a row from a textfile. input: 1 1 1 1 2 2 2 2 3 3 3 ...
  1. #1
    Just Joined!
    Join Date
    Jan 2009
    Posts
    3

    rows

    I would like to find a commando that would enable me to exract a row from a textfile.

    input:

    1 1 1 1
    2 2 2 2
    3 3 3 3

    output

    2 2 2 2

    Best wishes,
    Adam

  2. #2
    Trusted Penguin Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,392
    Hmmm, this looks like you're asking us to help you with your homework... Maybe you should read your coursebooks a bit more - but you could also try grep.
    Linux user #126863 - see http://linuxcounter.net/

  3. #3
    Just Joined!
    Join Date
    Dec 2007
    Location
    Bangalore
    Posts
    33
    You could try with a combi of head and tail commands

  4. #4
    Just Joined!
    Join Date
    Jan 2009
    Posts
    3
    I have no course and I have no coursebook. I'm just in need of creating a small bash script and I have very little time to browse through the litterature.

    It seemed to be a very simple problem so I figured that someone who knows linux could solve it in a few seconds while I have already spent some hours with the script. I would be very thankfull for the help.

  5. #5
    Just Joined!
    Join Date
    Dec 2007
    Location
    Bangalore
    Posts
    33
    This should work:
    $ head -n <filename> | tail -1

    where n= the number of the row to be printed

  6. #6
    Just Joined!
    Join Date
    Jan 2009
    Posts
    3
    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...