########################## 1 Simple Arguments

wc -l optimal_sampling.tex
grep -in --color flexibility optimal_sampling.tex
tail -n 50 optimal_sampling.tex
mkdir -p thesis/figs/ch4
#rm -rf !$
alias ls 'ls --color'


########################## 2 Pipes
# Redirect standard out to another program

# e.g. Extract an arbitrary chunk of file
head -n 55 optimal_sampling.tex | tail -n 11

head -n 55 optimal_sampling.tex | tail -n 11 | grep diurnal

head -n 75 data.tbl | tail -n 50 | grep 225


########################## 3 Pipes don't always work

#ls papers/*.pdf | evince          # This doesn't work

#evince `ls papers/*.pdf`          # This does work


########################## 4 Redirecting output to files

# Overwrite
find papers -name '*.pdf' > my_pdfs.dat

# Append
find talks -name '*.pdf' >> my_pdfs.dat


########################## 5 Redirecting input

phmoon < dates.in
phmoon < dates.in > dates.out
phmoon < dates.in | grep -o '[0-9.]\{5\}' > dates.out


########################## 6 Creating a shellscript
# i) Put #!/bin/tcsh on the first line
# ii) Fill your script with commands
# iii) Make the file executable: chmod +x script.csh
# iv) Run it: ./script.csh
