Readings

The readings for Monday, February 6 are:

  1. The Linux Command Line:

    • Chapter 19 - Regular Expressions
    • Chapter 20 - Text Processing
  2. RegexOne

    Work through the Lessons in the Interactive Tutorial.

TL;DR

The focus of this reading is to introduce regular expressions and revisit filters and pipelines.

Optional Resources:

Questions

In your reading03/README.md file, describe what command(s) you would use to accomplish the following:

  1. Convert all the input text to upper case:

    $ echo "All your base are belong to us" | ...
    ALL YOUR BASE ARE BELONG TO US
    
  2. Find and replace all instances of monkeys to gorillaz:

    $ echo "monkeys love bananas" | ...
    gorillaz love bananas
    
  3. Remove any leading whitespace from a string of text:

    $ echo "     monkeys love bananas" | ...
    monkeys love bananas
    
  4. 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 the format of /etc/passwd

  5. 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
    
  6. 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
    
  7. Given two text files, show all the lines that are present in both files.

  8. Given two text files, show which lines are different.

Feedback

If you have any questions, comments, or concerns regarding the course, please provide your feedback at the end of your response.

Submission

To submit your assignment, please commit your work to the reading03 folder in your assignments GitLab repository:

$ cd path/to/repository                   # Go to assignments repository
$ cd reading03                            # Go to reading directory
...
$ $EDITOR README.md                       # Edit README.md
$ git add README.md                       # Mark changes for commit
$ git commit -m "reading03: README.md"    # Record changes
...
$ git push                                # Send changes to GitLab