Biocomputing Fall 2018, Rowan University

Introduction to UNIX and Regular Expressions



Slides on regular expressions can be found here.

Unix Exercises

First, download this zip file day2things.zip, and double click it to unzip. Remember where on your computer it downloaded!

  1. Use the mv command to move the directory day2things to your home directory, and then navigate into this directory. Its path at this point should be ~/day2things. Use ls to examine its contents. Perform the rest of these exercises inside day2things.

  2. Use cp to make a copy of the file filewithstuff.txt named filewithstuff2.txt. Use the cat command to examine the contents of filewithstuff2.txt.

  3. Use the echo command with the > symbol to write the line “A new line!” (or honestly whatever you feel like typing) to the new file filewithstuff2.txt. Again examine the contents of this file with cat. What happened??

  4. Now Use the echo command with the >> (important!!!) symbol to write the line “A new line!” (or honestly whatever you feel like typing) to the ORIGINAL file filewithstuff.txt. Again examine the contents of this file with cat. What happened??

  5. Use the command wc to determine the number of lines in the file filewithstuff.txt.

  6. Use the command grep to find which lines contain a capital “L” in filewithstuff.txt.

  7. Use the command grep to count which lines contain a capital “L” in filewithstuff.txt.

  8. Use the command grep to find which lines do not contain a capital “L” in filewithstuff.txt.

  9. Use the commands grep and history (possibly with arguments!) to figure out how many times you’ve used the command cd recently.