What is the present working directory
What is the home directory
List all the files and sub-directories on Desktop
Create new directory on USB drive
Copy DNA dream file to new directory
cp $HOME/Desktop/DNAdream.txt /Volumes/USB_DRIVE/NAME
Remove DNA dream file on Desktop
rm $HOME/Desktop/DNAdream.txt
Check that your 'pwd' is your USB drive
To view text file content
Move files: mv <from> <to>
mkdir ./mgbootcamp
mv ./NAME/DNAdream.txt ./mgbootcamp
cd ./mgbootcamp
ls -l
Searching for specific phrase or file
grep “DNA” ./mgbootcamp/DNAdreaming.txt
grep –r “metagenomics” .
Wildcards (*)– when you do not remember nor type, or want multiple results
Assigning variables and strings
let DNA=2+2
let “BLUE=2*2”
echo $DNA
echo $BLUE
NUCLEOTIDES = ‘adenine, thymine, guanine, cytosine’
echo $NUCLEOTIDES
Create a new text file in terminal
nano ./loopy.sh
type #!/bin/bash
SEQUENCE=20
while [ $SEQUENCE –lt 50 ]
do
echo looping…
let SEQUENCE=$SEQUENCE+10
echo $SEQUENCE
done
echo ‘Done looping’
nano ./metadata.sh
#!/bin/bash
META=‘pH Salinity Temp Light’
for DATA in $META
do
echo $DATA
done
echo That is metadata!
Practice assignment - Can you 'nest' the loops, have one loop doing an arithmetic expression within another loop
Final project - Search through a directory of NGS files to find the ones with specific samples or barcodes. This is to help when it is not clear where samples were split across runs or when a barcode could have been used for multiple sequencing runs for a single project.
Using a text editor (not within the terminal) create a shell script
#!/bin/bash
echo What directory are you searching? USE COMPLETE FILE PATHS
read VDirectory
echo What directory/file are you writing to? USE COMPLETE FILE PATHS
read VOutputFile
echo How many samples are we going to search for? Enter a numerical value, such as 3
read VPhraseCount
until [ $VPhraseCount -le 0 ]
do
echo What sample are you searching for?
read VPhrase
echo Search Phrase: $VPhrase >> $VOutputFile
grep -o -c -r -i "$VPhrase" $VDirectory | grep -v :0
echo Processing...
grep -ocri "$VPhrase" $VDirectory * | grep -v :0 >> $VOutputFile
((VPhraseCount--))
done
echo Complete.
Run the shell script and follow prompts. Make sure to use complete file paths.