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.
- 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 ...