1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Find & grep - how to return pathes, not grep phrases ?

Discussion in 'Site & Server Administration' started by postcd, Nov 25, 2014.

  1. #1
    i used "grep -f patterns.txt phrases.txt" as a part of linux Find command.
    But the result is the phrasses not file names/file paths which is what i need..

    i need to search millions of files and 20 phrasses in each of the file that match Find parameters...

    this is end of my Find command:
    -exec grep -f my_phrasses.txt {} \;

    any idea how to return file pathes, not phrasses from my_phrasses.txt while maintaining low memory, cpu impact of the command? thx
     
    postcd, Nov 25, 2014 IP
  2. madaboutlinux

    madaboutlinux Member

    Messages:
    250
    Likes Received:
    7
    Best Answers:
    2
    Trophy Points:
    43
    #2
    Do you mean, you want to find a phrase in millions of files and you want the path to its files listed?
     
    madaboutlinux, Nov 27, 2014 IP
  3. postcd

    postcd Well-Known Member

    Messages:
    1,037
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    190
    #3
    yes, pathes to files which contains at least one phrasse from my_phrasses.txt
    i cant use grep alone as i have several parameters to linux "Find" that helps reduce amount of files that will be grepped
     
    postcd, Nov 27, 2014 IP
  4. samirj09

    samirj09 Well-Known Member

    Messages:
    335
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    125
    #4
    Your looking for the "-H" option in grep. You can also use the "-l" option to print just the filenames instead of the matches.
     
    samirj09, Dec 12, 2014 IP