Dr. Mark Humphrys

School of Computing. Dublin City University.

Online coding site: Ancient Brain

Search:


Linux Quiz 3

This quiz is for practice.
Everyone gets the marks if they make an honest attempt at the quiz.
Fill in every answer and press submit.
Your answers are stored on the server, where I may look at them to make sure you made an honest effort.
To keep a personal copy of your answers, press and then paste into a file.
We will do the answers in class.


Your name, etc.

Name
Student number
Practical password
  

Searching and manipulating files

  1. Go into my Shakespeare directory. How many sub-directories does it have?
    Do not count them by hand. Use "find" and pipe to "wc" to count them. Then the human will remove one from the count. Why?

    When I say "How many sub-directories ..." I am not looking for you to type in the number. Give me the command line that found the number.
    This applies to most of this page. Not really interested in the specific output. I am not interested in the command line needed.

  2. List all files called act1.html one level down from this directory.

  3. Find Act 3 of Macbeth. The size of this file is what?

  4. List all "Act 6" files in all plays.

  5. Write a command to check if any "Act 7" files exist.

  6. From your home directory, list all the "Act 6" files without changing directory.

grep

  1. Use "grep" to find all lines where "Ireland" appears in the plays. To avoid counting twice, only search all "complete.html"

  2. In the previous, in how many lines of the plays does "Ireland" appear?
    Use "grep" and "wc".

  3. In the previous, in how many different plays does "Ireland" appear?
    Use grep of the "complete.html" with a certain option to just list the files that have a match.

  4. Show all lines in the complete.html files that contain "Scot" but not "Scots" or "Scotland" or "Scottish".
    Run a grep and then pipe the result into more greps with a certain option.


  5. How many times does the string "Scotland" appear in Act 3 of a Shakespeare play?

    Q. How would you find the answer to the previous using Google or other search engine?
    I asked this question to ChatGPT and it failed. Maybe some LLM can do it?


  6. List all the plays in which the word "idiot" occurs.
    As above, see options for grep.

  7. List all the plays in which the word "idiot" does not occur.
    See options for grep.

  

grep of "test suite"

Go to my "test suite":
 cd /users/tutors/mhumphrysdculab/share/testsuite 
  1. List all the web pages (HTML files). They are all one level down.

  2. The pages are from my old server, which has moved.
    We need to change old links from "http://computing.dcu.ie/~humphrys/" to "https://humphryscomputing.com/".
    First, how do you search for the string "http://computing.dcu.ie/~humphrys/" in all the web pages?

    Q. How would you find that string in all the web pages using a Web browser? Or using a text editor?

  

File and directory size

  1. List the "testsuite" directories sorted by size.
    Use "du" and "sort".

  2. List the "act" files in Shakespeare sorted by size.
    Use "ls" or "du", along with "sort".

  
  


If you submit by mistake or make an error, just press "Back" and submit again.