SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Don't eat yellow snow spaceman's Avatar
    Join Date
    Mar 2001
    Location
    Melbourne, Australia
    Posts
    1,039
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    cat lines 200-300, with line numbers

    Until my copy of Redhat Linux Bible arrives...

    What's the cat (or other command) that I can use to display lines 200-300 (with line numbers) of a text file to the screen?

    Thanks.
    Web Design Perth Melbourne .:. Itomic Business Website Solutions
    Drupal Experts .:. Drupalise

  2. #2
    epsilon transition cupid's Avatar
    Join Date
    Aug 2001
    Location
    Kent, Ohio
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can cat it to get the line numbers and pipe the output to grep.

    cat -n filename | grep -E '(2|3)[0-9][0-9].*$'

    *oops forgot to mention grep -E is identical to egrep
    Last edited by cupid; Feb 16, 2002 at 15:57.

  3. #3
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am pretty sure you could do this with awk because the first variable of each line interpreted by awk is the line number, and you can use conditional logic in awk, so you could write something to print the line if the line number is >= 200 && <=300 but I can't help you on the syntaxt because my knowledge of awk is much too basic


Bookmarks

Posting Permissions

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