Skip to content

Latest commit

 

History

History
58 lines (31 loc) · 2.07 KB

answerkey-unix.md

File metadata and controls

58 lines (31 loc) · 2.07 KB

Exercise 1: "Starting with the shell"

  1. Login to O2 and start an interactive session.

Answer: ssh [email protected]

  1. Change directories into unix-intro.

Answer: cd unix-intro

  1. List the contents of the other directory. How many files are in the folder?

Answer: ls -l other

  1. Make a copy of the sequences.fa file and put it in the other folder. Name this file sequences-copy.fa.

Answer: cp other/sequences.fa other/sequences-copy.fa

Exercise 2: "Paths and shortcuts"

  1. Change directories into other. List all the Mov10 FASTQ files in raw_fastq from your current directory without changing directories.

Answer:

   ls -l ../raw-fastq/Mov10*
  1. Do each of the following using a single ls command without navigating to a different directory. HINT: You will want to use a wildcard here.

Answer:

* List all of the files in /bin that start with the letter 'c': `ls /bin/c*`
* List all of the files in /bin that contain the letter 'a': `ls /bin/*a*`
* List all of the files in /bin that end with the letter 'o': `ls /bin/*o`
* BONUS: List all of the files in /bin that contain the letter 'a' or 'c'. (This was not covered in the lesson): `ls *[ac]*`

Exercise 3: "Examining files, searching and redirection"

  1. Print the contents of sequences-copy.fq to the screen.

Answer: cat sequences-copy.fq

  1. Use the head command to keep only the first two sequences of this file.

Answer: head -n 2 sequences-copy.fa

  1. The last two lines of the file sequences-copy.fa represent a protein sequence. Use the tail command to take those two lines and redirect them into a new file called protein.fa.

Answer: tail -n 2 sequences-copy.fa > proetin,fa

  1. Use grep to search for the patterm CAGCT in the sequences-copy.fa file. Use your shell knowledge to count how many times that pattern appears in the file. Now use the man pages to find out how you can count using the grep command.

Answer: grep CAGCT sequences-copy.fa | wc -l

     `grep -c CAGCT sequences-copy.fa `