Thread: Grep Last Pattern Output

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    20

    Grep Last Pattern Output

    Hi

    Is there any way with grep to show me only the last pattern that matches and not all ? For example for a file with

    linux 56
    slackware 32
    debian 34
    linux 2
    redhat 9

    and $> grep linux filename

    show me only --> linux 2
    and not

    linux 56
    linux 2

    Thanks

  2. #2
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    grep foo filename | tail -1


    off topic: woohoo, post 10 hundred!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. code output...
    By roaan in forum C Programming
    Replies: 6
    Last Post: 07-03-2009, 02:22 AM
  2. Help for my output array
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 02-17-2009, 03:08 PM
  3. execl()/fork() output
    By tadams in forum C Programming
    Replies: 19
    Last Post: 02-04-2009, 03:29 PM
  4. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 05:10 PM
  5. sorting output on student info program
    By indigo0086 in forum C++ Programming
    Replies: 2
    Last Post: 11-05-2002, 11:29 AM