This week the readings will focus on regular expressions and filters. These additional tools will come in handy when we want to write more advanced shell scripts that slice and dice data.
The readings for Monday, February 22 are:
RegexOne Learn Regular Expressions with simple, interactive exercises.
Work through the Lessons in the Interactive Tutorial.
Optional Resources:
Digital Ocean Tutorials:
In your reading06/README.md
file, describe what command(s) you would use to
accomplish the following:
Convert all the input text to upper case:
$ echo "All your base are belong to us" | ...
ALL YOUR BASE ARE BELONG TO US
Parse the /etc/passwd
file for the shell of the root
user:
$ cat /etc/passwd | ...
/bin/bash
Hint: You may need to read up on /etc/passwd
Find and replace all instances of monkeys
to gorillaz
:
$ echo "monkeys love bananas" | ...
gorillaz love bananas
Find and replace all instances of /bin/bash
, /bin/csh
, and /bin/tcsh
to /usr/bin/python
in /etc/passwd
:
$ cat /etc/passwd | ... | grep python
root:x:0:0:root:/root:/usr/bin/python
mysql:x:27:27:MySQL Server:/var/lib/mysql:/usr/bin/python
xguest:x:500:501:Guest:/home/xguest:/usr/bin/python
condor:x:108172:40:Condor Batch System:/afs/nd.edu/user37/condor:/usr/bin/python
lukew:x:522:40:Luke Westby temp access:/var/tmp/lukew:/usr/bin/python
Remove any leading whitespace from a string of text:
$ echo " monkeys love bananas" | ...
monkeys love bananas
Find all the records in /etc/passwd
that have a number that begins with
a 4
and ends with a 7
:
$ cat /etc/passwd | ...
rtkit:x:499:497:RealtimeKit:/proc:/sbin/nologin
qpidd:x:497:495:Owner of Qpidd Daemons:/var/lib/qpidd:/sbin/nologin
uuidd:x:495:487:UUID generator helper daemon:/var/lib/libuuid:/sbin/nologin
mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin
Follow the trailing output of a set of log files.
Given two files, show all the lines the are present in both files.
In the reading06
folder, write at least five summary pages for the
following commands:
Note, your summaries should be in your own words and not simply copy and pasted from the manual pages. They should be short and concise and only include common use cases.
If you have any questions, comments, or concerns regarding the course, please provide your feedback at the end of your response.
To submit your assignment, please commit your work to the reading06
folder
in your Assignments Bitbucket repository by the beginning of class
on Monday, February 22.