1. Suppose we have a file directories.txt where each line contains the name of a directory that we want to create. Our friend proposes that we run cat directories.txt | mkdir into order to do this? Will this command work? If not, how can we change this command to get it to work/could we improve it in any way?

  2. Come up with a general statement about when we need to use the xargs command.

  3. Suppose we have the intro_survey.csv from the previous homework assignment. Using cut, how many unique answers were there to the question “What’s your favorite candy”?

  4. Suppose we have the intro survey data below. Let’s try to print the column “Cats or Dogs?” from this data. First, come up with a cut command you might use to do this. Second, predict whether or not this will work for the data below. Third, run the cut command on the data below. Did it work? Why or why not?

What's your favorite candy?,What's your favorite dinner?,Cats or Dogs?,Are you currently enrolled in CSE 351?
Peanut M&Ms,Sandwich,Either,No
Snickers,rice, pork, and cabbage,Dogs,No
Sour skittles,thai,Dogs,No
sour patch, starburst,Dumplings,Cats,No
  1. Write a command that lists all the import statements in any *.java files within the current directory and its subdirectories. For this problem, you can assume that an import statement just has the word “import” in it. Bonus points: also show the line number!

  2. Write a command that would delete all directories, recursively, starting from the current directory. Be careful about where you run this command!! Don’t run it from your home directory!

  3. Suppose we were given a zip file called files.zip. Come up with a one-line shell statement that unzips all of its contents and then compiles all of the *.java files inside of it.

  4. Suppose we know that Compile.java compiles with no errors. If we were to run javac Compile.java || java Compile what would be the result? Would the program compile? Would it run?

  5. What would be some security issues with running some of the commands you learned from lecture (think of some of the practical implications of rm, find, and xargs in regards to malicious code injection)?