Cybersecurity Ops with bash - Chapter 7 Solutions

Below are selected solutions for the Chapter 7 workshop questions from Cybersecurity Ops with bash.

Question 1

The following example uses cut to print the first and tenth fields of the access.log file:

cut -d' ' -f1,10 access.log | bash | sort -k 2.1 -rn

Replace the cut command with the awk command.


Since the access.log file uses whitespace as a field delimiter, you can use awk to access each field (column) directly using $ and the field number.

Question 3

Use the tr command to replace all of the semicolon characters in tasks.txt with the tab character and print the file to the screen.


Note that the tr command does not read a file directly, but rather accepts input from stdin.

153 views0 comments

© 2020 by Paul Troncone and Carl Albing