Exercises

4.5. Exercises

These exercises will help you master regular expressions.

  1. Display a list of all the users on your system who log in with the Bash shell as a default.

  2. From the /etc/group directory, display all lines starting with the string "daemon".

  3. Print all the lines from the same file that don't contain the string.

  4. Display localhost information from the /etc/hosts file, display the line number(s) matching the search string and count the number of occurrences of the string.

  5. Display a list of /usr/share/doc subdirectories containing information about shells.

  6. How many README files do these subdirectories contain? Don't count anything in the form of "README.a_string".

  7. Make a list of files in your home directory that were changed less that 10 hours ago, using grep, but leave out directories.

  8. Put these commands in a shell script that will generate comprehensible output.

  9. Can you find an alternative for wc -l, using grep?

  10. Using the file system table (/etc/fstab for instance), list local disk devices.

  11. Make a script that checks whether a user exists in /etc/passwd. For now, you can specify the user name in the script, you don't have to work with arguments and conditionals at this stage.

  12. Display configuration files in /etc that contain numbers in their names.


196 visits (2 today, 14 this week, 32 this month, 196 this year)
Uptime: 08:12:37 up 3 days, 13:56, 3 users, load average: 0.00, 0.05, 0.02
3.147.69.213 GET from server z.lamurakami.com

Saturday, December 21, 2024 @ 8:12:37 AM
z.ServerAdmin@lam1.us