Results 1 to 3 of 3

Thread: Using bash to print the third word in a line

  1. #1
    Join Date
    Oct 2006
    Beans
    324

    Question Using bash to print the third word in a line

    Is there a way to print out the 3rd word of a line found in a file?

    Can i do this with grep??

  2. #2
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: Using bash to print the third word in a line

    awk is probably a better choice:
    Code:
    awk '/PATTERN/{print $3}' file

  3. #3
    Join Date
    Oct 2006
    Beans
    324

    Re: Using bash to print the third word in a line

    Quote Originally Posted by sisco311 View Post
    awk is probably a better choice:
    Code:
    awk '/PATTERN/{print $3}' file
    ok thanks a lot
    i did
    Code:
    awk '{print $3}' file
    and it worked

Tags for this Thread

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
  •