Dr. Mark Humphrys

School of Computing. Dublin City University.

Online coding site: Ancient Brain

coders   JavaScript worlds

Search:

Free AI exercises


Linux Quiz 3



  

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 "wc" to count them. 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 complete.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. From your home directory, list all the "Act 6" files without changing directory.

grep

  1. In how many lines of the plays does the string "for Ireland" (exact case) appear?
    Use "grep" to search all "complete.html" and then use "wc".
  2. In how many different plays does the string "for Ireland" appear?
    Use grep of the "complete.html" with a certain option to just list the files that have a match.
  3. 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 another grep with a certain option.
  4. 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?
  5. List all the plays in which the word "because" occurs.
    As above, see options for grep.
  6. List all the plays in which the word "because" 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. We have converted the DCU web server from http: to https:
    We need to change old links from "http://computing.dcu.ie" to "https://www.computing.dcu.ie".
    How do you search for the string "http://computing.dcu.ie" 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 Shakespeare 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.