David King
David King

Reputation: 91

grep --include="" takes a lot longer than filename

I am trying to grep recursively through 100 folders each with 20000-40000 files in them.

If I go into a folder and run :

grep -l "Search_String" File_Name_Starts_With* | xargs ls -lt 

it returns the results, I want, in less than 1 second.

If I run:

grep -l --include="File_Name_Starts_With*" "Search_String" | xargs ls -lt

it sits there for a long time... 15 min is the longest I have let it sit with no result before cancelling.

I assume I am doing something wrong, as this is my first attempt at this.

Upvotes: 2

Views: 992

Answers (1)

ryekayo
ryekayo

Reputation: 2431

I figure I will place my comment as the answer. In your second search, you need to provide a directory path or a file:

grep -l --include="File_Name_Starts_With*" "Search_String" <path_or_file> |
xargs ls -lt

Upvotes: 1

Related Questions