July 2018
Beginner
264 pages
8h 9m
English
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.
#!/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 ...Read now
Unlock full access