More fun stuff..
stay tuned for some cool commercials after the content! LOL
file: describes the contents of a file
cat: outputs the content of a file, associated with the stdout.d library.
How do we find how many javascript calls cnn.com makes?
pseudocode:
1: pull javascript calls doc from cnn
1.5 load them into a txt file.
2. parse calls by delineating calls with script
3. count calls with script file
4 you are the man.
cat cnnindex.txt | grep -i “text/javascript” | wc -l
What did we learn here:
wc = word count
piping commands channels output sequentially making things act like batman.
a javascript call looks like this: <script type:”text/javascript”>
again:
Pull the contents of a file down from the net with curl or wget
use the > delimiter to output that command to a file, in this case cnnindex.txt
open the file up and learn something about javascript calls… we know what they look like from the line just above this paragraph.
grep -i with the text that designates the code as a javascript call inside double quotes,
and pipe again, that contents to the word count command which counts the number of instances pulled back from the contents we piped to the grep command.
our output was 20 and we are now the man.