1 Ownership and permissions

Q: Change permission from ---------- to -rw-rw—wx.

One answer:

chmod ug+rw filename  
chmod o+wx filename  

3 Grep

Command to grep all lines with chr1 and send to other file.

ex:

grep "chr1" sample_1.sam > chr1.txt

4 WC

grep "chr1" sample_1.sam | wc -l
samtools view outbam.bam | grep "CATCATCAT" | wc -l

5 Extra material 1

Task 1:

grep "^@" sample_1.sam > at.txt

Task 2:

grep "[0-9]\{3\}$" sample_1.sam

6 Extra material 2

sed 's/chr1/chr2/' sample_1.sam > sample_2.sam

7 Extra material 3

for f in *.sam; do mv $f ${f/.sam}.bam; done

End of document