The last two chapters gave you all of the parts for a report. Put them together.
The parts
| You need | Use |
|---|---|
| A number alone | wc -l < file |
| Some lines | grep, grep -v |
| One column | cut -d' ' -fN |
| A ranking | sort | uniq -c | sort -rn |
| The top N | head -n N |
| Start a report file | > |
| Add to the report | >> |
Build it one step at a time
1. Run the first command aloneread the output
2. Add one | step at a timecheck the output after each one
3. Save to the report> for the first line, >> after it
4. Check the filecat the report
An example
text
learner@tidepool:~$ wc -l < visits.log > report.txt
learner@tidepool:~$ cut -d' ' -f3 visits.log | sort | uniq -c | sort -rn | head -n 1 >> report.txt
learner@tidepool:~$ cat report.txt
5
3 /menuLine 1 of the report is the number of visits. Line 2 is the most visited page and its count.