Patrick Cahan
Getting started. Launch the Terminal
Make a new directory
mkdir ~/bootcamp2016/Day2
Change current working directory
cd ~/bootcamp2016/Day2
Directory listing
ls -lath
Creating new files
touch aFile.txt
Make a copy of the file
cp aFile.txt aNewFile.txt
Moving a file
mkdir dumpingZone
mv aNewFile.txt dumpingZone/
Deleting files
rm aNewFile.txt
ls -lath
touch a.txt
touch b.txt
touch c.txt
touch d.csv
Move all .txts
mv *.txt dumpingZone/
ls -lath
ls -lath dumpingZone
echo $PATH
echo $HOME
emacs ~/bash_profile
Add ~/bootcamp2016/Day2/dumpingZone to your path
Ctrl x-s to save file
Now source it
source ~/.bash_profile
echo $PATH
Grep searches for string matches in a given input
grep Harvard ../Day1/timesData.csv
Awk selects columns
awk 'BEGIN { FS = "," } ; {print $2,$1}' ../Day1/timesData.csv
Piping output
grep Harvard ../Day1/timesData.csv | awk 'BEGIN { FS = "," } ; {print $2,$1, $15}'
"The primary World Bank collection of development indicators, compiled from officially-recognized international sources. It presents the most current and accurate global development data available, and includes national, regional and global estimates."
Data source: http://datacatalog.worldbank.org/
Download the data from:
http://www.cahanlab.org/intra/training/bootcampJune2016/misc/WDI_csv.zip.
Save it to ~/bootcamp2016/Day2/homework
Unzip the compressed file:
unzip WDI_csv.zip