CSCI 3215 (Advanced UNIX Command-Line Tools), Fall 2022:
Reading Quiz 3

Credit:
10 points.

Reading

Be sure you have read, or at least skimmed, the reading for 9/21.

For most courses I ask that you answer questions on reading quizzes using only the assigned readings for the course. For this course, however, while I mean for you to be able to answer the questions based on the assigned readings, plus sometimes man and info pages, you can consult any source you like. (So, Web searches are AOK.) It's okay to talk to classmates about this assignment as you usually do, but I want each person to at least skim all the reading. Include the Honor Code pledge in what you turn in, either the full pledge or just the word “pledged”. For these quizzes by doing this you are also saying you have at least attempted or skimmed all the reading it covers.

Please put the pledge in the same document as your answers, so I don't overlook it, and please be sure to include your name somewhere in the file, so when I print it for grading I know whose work it is.

You may write out your answers by hand and scan them, or you may use a word processor or other program, but please submit PDF or plain text in the “turn-in” folder I have set up for you on Google Drive. (So, no word-processor files, including Google Docs, and no links to other Google Docs.)

Questions

  1. (2.5 points) In one of the lectures in this class, I mention “tab completion” (getting bash to complete long filenames, e.g.). It behaves slightly differently on this year's build (on the classroom machines) and the previous builds (on, e.g., the DIAS cluster dias01--dias05). Apparently how this feature behaves depends on configuration files in /etc/bash_completion.d, which must be different on the two machines. One way to compare them would be to log into, say, dias01 and make a copy of this directory in your own home directory, and then log into one of the classroom machines and compare it to the copy in /etc on the classroom machine. What command could you use to do the comparison?

  2. (2.5 points) How do you use grep to search all files ending .txt in the current directory for your username? Is there a way to make the search recursive -- i.e., the current directory and all subdirectories? Can you make grep print not the matching lines but just the names of the files containing a match?

  3. (2.5 points) By default, sort sorts in lexicographical order (meaning that it ignores case and leading blanks). If you're sorting numbers, though, this is likely not what you want. How do you make it sort in numerical order instead?

    For extra credit: How can you instead make it sort using the same comparison the C function strcmp() does -- i.e., case sensitive, including any leading blanks. (Hint: This will require setting an environment variable.) (I said in a previous version that this was a harder problem than I thought, and the method I used to use stopped working? I was mistaken. It still does. It's still worth a little extra credit.)

  4. (2.5 points) What would you type at the command line to find all files in your home directory (and all subdirectories) that have been modified within the past 24 hours and end with .c?




2022-10-02