Reputation: 27
I can do the following to search for what I need and return the file name: grep -l "mysearchstring" ./*.xml However the files I am searching are huge so this takes forever. The string I am searching will appear in the first 200 rows so how can I search only the first 200 rows and still return the file name? Thanks
Upvotes: 1
Views: 65
Reputation: 785058
You can do:
for file in *.xml; do
head -200 "$file" | grep -q "mysearchstring" && echo "$file"
done
Upvotes: 5