The site was slow overnight. Your manager asks which address sent the most requests. The web server log, access.log, has 5000 lines, one per request, and the first word of each line is the client's address. A colleague sent a command that answers this kind of question — run it.
Run your colleague's command
In ~/pipe-lab, look at the first two lines of the log, then run your colleague's command.
First, predict
What will your colleague's command print?
Now start the exercise, run the command and compare your prediction with the output.
Only cut was given the file name access.log. Where did sort, uniq and head get their lines?
-
No new files appeared in the directory — check with
ls. The lines went from command to command directly. -
Three lines reached the screen, while sort received 5000 addresses. Between the commands the lines bypassed the screen.
-
With no file name, sort, uniq and head open no files. Run
sortwith no arguments: it waits for text from the keyboard; Ctrl+C gets you out.
The | sign passed each command's output to the input of the next.