Sunday, July 24, 2011

wreckergrep One-Liner

 find . -iname "<search_pattern>" -print | while read f; do grep -Ril <search_file_content> "$f"; done

OR

#!/bin/bash
# wreckergrep.sh
find . -iname "<search_pattern>" -print | while read f; do
  grep -Ril $1 "$f"
done




Okay,

Now save the file as wreckergrep.sh and change your permissions:
chmod 755 wreckergrep.sh

Use your new utility with the following syntax:

./wreckergrep.sh <search_file_pattern>

So, for example running the one-liner:
 find . -iname "*.py" -print | while read f; do grep -Ril http "$f"; done


Will return every python file containing the search_file_pattern "http"

Hopefully this helps ya out in a pinch ;)


Later skaterz ;)

No comments:

Post a Comment