Good questions? Good question...

Jun 20, 2013 • Katie Cunningham

I was inspired by the varying depth of multiple choice questions in a CalTech Machine Learning MOOC I recently participated in. The period for certification is over, so now the homework sets are open to the public. All homework sets were 10 multiple choice questions, but some questions were much more difficult than others. In the most difficult questions, the learner had to build a functioning program in order to obtain the answer. I think it’s very impressive that the professor chose questions where the final answer was unambiguous despite the fact that each student was creating their own medium-sized program.

I was also impressed with the quality of teaching in general in that MOOC. MOOC students got a similar experience as CalTech students, in that the recordings students watch are recordings of a live classroom (from a year or so ago). In addition, there is a forum that online students can use, and there is a question and answer session after each lecture, with questions both from the CalTech audience and the online audience that was live when the videos were recorded. Even though the course was a “sage on the stage” classic lecture model, with Professor Abu-Mostafa talking to his live class / the camera for an hour twice a week, I felt that the teaching was very well-done. And I guess I’m not the only one who thinks that, because he was given a boatload of teaching awards. Understanding why Prof. Abu-Mostafa is such a good teacher is one of my goals for this class. So far I think that the question and answer session after each of his lectures, his concise but frequent answers on the forums, and his skill in repeating key ideas during lectures are pieces of the puzzle.

Anyway, on to my questions, which are on the topic of bash shell commands:

Q1: Match the bash command to the best description of its function

1. ls       A. Change location in the filesystem

2. wc       B. Make a new folder (aka directory)

3. cd       C. Move or rename something

4. mkdir    D. Remove a file permanently

5. mv       E. List the name of everything

6. rm       F. Show the number of characters, words, and/or
               lines in something

A1: 1-D, 2-F, 3-E, 4-B, 5-A, 6-C

A2: 1-E, 2-F, 3-A, 4-B, 5-C, 6-D

A3: 1-E, 2-A, 3-C, 4-F, 5-B, 6-D

 

Q2: I want to know how many items are in my current directory. One way I could do that is to count how many lines there are when I list the contents of the current directory. Which of these is a correctly structured bash command that will achieve that goal?

A1. | wc

A2. ls | wc |

A3. ls | wc

A4. ls || wc 

 

Q3: Now I want to list each file in my current directory and then list how many characters, words, and lines are in that file. Which of the following commands achives that goal?

1. ls | wc

2. for f in *
     do
       echo $f
       wc $f
     done

3. for f in *:
     cat f
     wc  f

4. cat * | wc