How to do it...

Using the data obtained by recursively crawling the Packt Publishing website, we can see that inside of www.packtpub.com the entire website is available. Wow! We also created some test data directories and files.

  1. Next, open up a terminal and create the following script:
#!/bin/bash# Let's find all the files with the string "Packt"DIRECTORY="www.packtpub.com/"SEARCH_TERM="Packt"# Can we use grep?grep "${SEARCH_TERM}" ~/* > result1.txt 2&> /dev/null# Recursive checkgrep -r "${SEARCH_TERM}" "${DIRECTORY}" > result2.txt# What if we want to check for multiple terms?grep -r -e "${SEARCH_TERM}" -e "Publishing" "${DIRECTORY}" > result3.txt# What about find?find "${DIRECTORY}" -type f -print | xargs grep "${SEARCH_TERM}" > result4.txt ...

Get Bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.