git clone https://github.com/juliusv/cli_exercises.git
cd cli_exercises
- How many lines does the "words" file contain?
- How many lines in the "words" file contain the word "foo" anywhere on the line?
- Print the "words" file in reverse lexicographic order
- Print the lines of the "words" file which contain "foo" in reverse lexicographic order
- Same as 4., but exclude words containing single quotes
- Same as 5., but replace all occurrences of "foo" with "fa"
- How many files underneath /etc end with ".conf"?
- Which lines are different between the "words" and "words2" dictionary files?
- How long has it been since your computer was started?
- How many free bytes do you have left on your root (/) filesystem?
- How many bytes does the "cli_exercises" directory take up?
- How large is the "words" file in bytes?
- How many unique visitors (unique IP addresses) does the "access.log" file contain?
- Same as 13., but restrict this to only hits on March 8th
- Same as 14., but instead of counting them, write the visitors' IP addresses to a new file, named "access_mar_8.log"
- Print the first and last 20 lines of "access.log" into a new file named "short.log"
-
wc -l words
or
wc -l <words
or
cat words | wc -l
-
grep foo words | wc -l
-
sort -r words
-
grep foo words | sort -r
-
grep foo words | grep -v "'" | sort -r
or
grep foo words | grep -v \' | sort -r
-
grep foo words | grep -v "'" | sed 's/foo/fa/' | sort -r
-
find /etc -name "*.conf" | wc -l
-
diff -u words words2
or
diff -u words{,2}
-
uptime -s
-
df -h /
-
du
-
ls -l words | cut -d" " -f5
or
wc -c words
-
cut -f1 -d" " access.log | sort -u | wc -l
or
awk '{ print $1 }' access.log | sort -u | wc -l
-
grep '07/Mar/2004' access.log | cut -f1 -d" " | sort -u | wc -l
-
grep '07/Mar/2004' access.log | cut -f1 -d" " | sort -u > access_mar_8.log
-
head -n 20 access.log > short.log; tail -n 20 access.log >> short.log
or
(head -n 20 access.log && tail -n 20 access.log) > short.log