Ling 555 — Programming for Linguists
Robert Albert Felty
Speech Research Laboratory Indiana University
- Sep. 03, 2008
Ling 555 Programming for Linguists Robert Albert Felty Speech - - PowerPoint PPT Presentation
Ling 555 Programming for Linguists Robert Albert Felty Speech Research Laboratory Indiana University Sep. 03, 2008 How programming will make your life easier An easier life Example Unix basics I recently discovered that a portion of
Speech Research Laboratory Indiana University
# this snippet removes all clipped files, by checking the output from sox for file in `find . -name "*.wav" -print`; do if [[ `sox $file -n stat 2>&1 | grep -E "^(Try:|Can't|(Min|Max)imum amplitude:\s+-?1\.00)"` ]]; then echo "$file CLIPPED"; mv $file $file.clipped; fi; done 4
navigation The PATH permissions Reading files Pipes and streams
1
2
3
5
navigation The PATH permissions Reading files Pipes and streams
6
navigation The PATH permissions Reading files Pipes and streams
~ is a shortcut for your home directory. E.g., your
7
navigation The PATH permissions Reading files Pipes and streams
/usr/local/bin, and one in /bin, whichever one comes
8
navigation The PATH permissions Reading files Pipes and streams
echo $PATH
export PATH="/some/new/path:${PATH}"
which foo 9
navigation The PATH permissions Reading files Pipes and streams
drwxr-xr-x 4 robfelty root 4096 Jul 10 23:02 fender4star
1 robfelty robfelty 1137 Aug 19 14:12 syncWithDreamhost lrwxrwxrwx 1 robfelty yootlers 21 Jun 9 10:43 images -> ../fedibblety/images/ 10
navigation The PATH permissions Reading files Pipes and streams
chown, chgrp, chmod
chown john johnsfile.txt
chgrp johnandmary johnsfile.txt
chmod a+x myFirstPythonScript.py 11
navigation The PATH permissions Reading files Pipes and streams
12
navigation The PATH permissions Reading files Pipes and streams
sort -t '\' -k 3,3rn -k 2,2fd celex.cd > celex.sorted 13
navigation The PATH permissions Reading files Pipes and streams
ls | head
cut -f 3 -d '\' celex.cd |sort -rn |uniq -c 14
navigation The PATH permissions Reading files Pipes and streams
cat < foo
ls > foo.txt
ls >> foo.txt
ls 2> error.txt 15
navigation The PATH permissions Reading files Pipes and streams
echo `basename l55practiceFiles/a.txt .txt` 16
Practice
head -n 25 foo 17
Practice
man foo
18
Practice
1
ls | head -n 20 | tail OR ls | tail -n +11 | head
2
ls | nl
3
ls | wc -c
4
mkdir tmp mv `ls | head -n 20 | tail` tmp 19
KISS TMTOWTDI The three virtues
20
KISS TMTOWTDI The three virtues
21
KISS TMTOWTDI The three virtues
1
2
3
22
KISS TMTOWTDI The three virtues
1
2
3
22
KISS TMTOWTDI The three virtues
1
2
3
22
KISS TMTOWTDI The three virtues
1
2
3
22
23