Find the answer to your Linux question:
Results 1 to 3 of 3
Hi, I have a file like this: user1 helloblabla user2 blauser1bla I need to grep user1 but Only the line where user1 is the first word. How do I do ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2012
    Posts
    44

    grep first word


    Hi,

    I have a file like this:

    user1 helloblabla
    user2 blauser1bla
    I need to grep user1 but Only the line where user1 is the first word. How do I do this?

    If I run "grep user1 file.txt" it will grep both lines..

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,380
    Code:
    egrep '^user1' file.txt
    You must always face the curtain with a bow.

  3. #3
    Just Joined!
    Join Date
    Apr 2012
    Posts
    44
    Wow that was fast!

    Thanks a lot, it works perfectly!

Posting Permissions

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