LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   grep for http link in binary files (https://www.linuxquestions.org/questions/linux-general-1/grep-for-http-link-in-binary-files-791799/)

Genjix 02-26-2010 01:57 PM

grep for http link in binary files
 
Hey,

grep -Rn domainnameofwebsite .

Binary file ./blaaA matches
Binary file ./blaaB matches
Binary file ./blaaC matches
Binary file ./blaaD matches
...

How can I get grep to output the entire link? Is there a way to have it show 20 characters forward from where it finds my search string?

Thanks ;)

MensaWater 02-26-2010 02:08 PM

You might want to try something like
for httpfile in `ls .`
do echo "File is $httpfile and grep shows:"
strings $httpfile |grep domainnameofwebsite
done

The strings command looks for text in a binary and prints it out. (Of course it prints a lot of gobbledygook as well but your grep should restrict it to the information you want.

Genjix 02-26-2010 02:13 PM

thank you! that's amazing


All times are GMT -5. The time now is 11:02 AM.