Commands Used:
grep <arg1> <arg2>
1) What would the regular expression be to search through the /var/log/messages files for an IP address?
2) In the student user’s home directory, what does the following command return?
grep ‘in’ teams.txt
3) In the student user’s home directory, what does the following command return?
grep ‘i[nc]’ teams.txt
4) From our regex cheatsheet, break down the Date regex from the Sample Patterns box at the bottom.
(\d{1,2}\/\d{1,2}\/\d{4})
How many symbol groups (combinations of symbols, numbers and letters that have a specific meaning in a regex – for instance \s for any spaces is one symbol group) are there in this regex, and what are they?
5) What does the first symbol group do?
6) What does the final symbol group do?
7) What is a limitation of this regex?
Commands Used:
grep <flag> <arg1 – searchstring> <arg2 – path>
8) What is a regex to capture the date in year-month-day format?
9) What is the command to search our teams.txt file to show any line with either Bears or Seahawks?
10) What would the regular expression be to use with grep to search the /var/log/messages file and search for either apache or http?