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
Advertisement
Answer
You can do:
for file in *.xml; do head -200 "$file" | grep -q "mysearchstring" && echo "$file" done