Below are selected solutions for the Chapter 5 workshop questions from Cybersecurity Ops with bash.
Write the command to search the filesystem for any file named dog.png.
You can use the find command to search the file system:
Write the command to search the file system for any file containing the text secret or confidential and copy the file to your current working directory.
You can combine the find command with the exec option to invoke the egrep command to search the content of each file, and then the cp command to copy any matching files to the current working directory:
Modify winlogs.sh to indicate its progress by printing the logfile name over the top of the previous logfile name. (Hint: Use a return character rather than a newline.)
The winlogs.sh script contains the line below that prints the name of each log file to the screen.
The echo command automatically prints a newline after each iteration. To print everything on the same line you can replace echo with the printf command and the carriage return (\r) character.
Note that the carriage return only moves the cursor to the beginning of the line, it does not clear the line. If the next item to print is shorter than the previous item some of the previous item's text will remain on the line. We will discuss how to solve this in Chapter 12 with the tput command.