#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    208
    Rep Power
    13

    Finding a string


    Hi,

    I would like to find a string and the file where the string belongs to in Unix. From a command line, I typed,

    cat *.pc | grep "this string"

    It returns the string but it does not tell me in which file the string belongs to.

    How would you do?

    Thanks.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,442
    Rep Power
    1688
    The man pages are your friend:

    Code:
    grep -l "this string" *.pc
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    208
    Rep Power
    13
    Thanks.

IMN logo majestic logo threadwatch logo seochat tools logo