Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2006
    Posts
    1,112

    Linux get last line of output

    Hi

    What command could I use to get the last line of an output?

    Heres why...

    I use this command:

    Code:
    netstat -plan|grep :80|awk {'print $5'}|cut -d: -f 1|sort|uniq -c|sort -nk 1
    I would like to get just the last line of the output, the output looks like this:

    Code:
    1 203.118.105.*
    1 80.195.165.*
    1 87.211.51.*
    1 91.40.90.*
    8 82.2.222.*
    213
    The reason is because I'd like to get that last figure to place into a file on a certain time period (through a cron), which will then be graphed with PHP.

    Thanks!

  2. #2
    Join Date
    Apr 2005
    Location
    Cochin
    Posts
    2,452
    netstat -plan|grep :80|awk {'print $5'}|cut -d: -f 1|sort|uniq -c|sort -nk 1 | tail -1

  3. #3
    Join Date
    Jun 2006
    Posts
    1,112
    Thanks very much!

    To be honest, I should of thought of that myself. "tail" is one of the very few commands(?) I know in Linux!

    Again though, thanks alot

  4. #4
    Join Date
    Apr 2005
    Location
    Cochin
    Posts
    2,452
    Quote Originally Posted by ST-Mike View Post
    Thanks very much!

    To be honest, I should of thought of that myself. "tail" is one of the very few commands(?) I know in Linux!

    Again though, thanks alot

    Take care Mike

Posting Permissions

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