Show line number? - Use "grep"?


Results 1 to 5 of 5

Thread: Show line number? - Use "grep"?

  1. #1
    Join Date
    Oct 2003
    Posts
    65

    Show line number? - Use "grep"?

    Man this seems like it would be really easy, but all I want to do is show a particular line from a file. I looked up the "grep" man page and couldn't find anything that worked. I don't have to use "grep", anything will do. So how would someone show line 22 from the file "log"???

  2. #2
    Join Date
    Feb 2002
    Location
    NC, USA
    Posts
    33
    How about using vi?
    AMD Athlon 1.3 Ghz
    Fedora Core 1
    512 MB RAM
    Nvida Riva TNT2 Video Card

  3. #3
    Join Date
    Feb 2003
    Location
    New Jersey USA
    Posts
    62
    Here's a simple way using the commands head & tail...
    If you only want to look at line 22 of a particular file "log", run the following command:
    $ head -22 log |tail -1

    That will print line 22 out.

    Anyone else have any other ideas?

  4. #4
    Join Date
    Apr 2003
    Location
    Buenos Aires, Argentina
    Posts
    4,219
    mcedit (which is a part of Midnight Commander) shows you all that info when you're editing any file.
    djserz.com.ar
    "All the drugs in this world won't save you from yourself..."

  5. #5
    Join Date
    Oct 2003
    Posts
    65
    Originally posted by ernieg
    Here's a simple way using the commands head & tail...
    If you only want to look at line 22 of a particular file "log", run the following command:
    $ head -22 log |tail -1

    That will print line 22 out.

    Anyone else have any other ideas?
    Thanks, this is exactly what I was looking for!!! I should make a shell script call showline using head and tail. Once again, 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
  •