Resources for Computational Linguists seminar ss07 unix tools Michaela Regneri Magdalena wolska 30 April 2007 SS07 – Res4CompLingsts – unix /30
cat file btw, man command less / more file head [-n] / tail [-n] file | cat file | less wc file paste file1 file2 30 April 2007 SS07 – Res4CompLingsts – unix /30
grep pattern file grep „a” testtext.txt grep „^a” testtext.txt grep „^A” testtext.txt grep „c$” testtext.txt grep „a.*d” testtext.txt grep –i „a” testtext.txt grep „[Aa]” testtext.txt grep –v „[Aa]” testtext.txt 30 April 2007 SS07 – Res4CompLingsts – unix /30
sort file sort testtext.txt sort –r testtext.txt sort testnums.txt sort –n testnums.txt sort –rn testnums.txt uniq file uniq testtext.txt sort testtext.txt | uniq sort testtext.txt | uniq -c 30 April 2007 SS07 – Res4CompLingsts – unix /30
tr – translate or delete chars tr ‘a-z’ ‘A-Z’ < example.txt tr –c ‘0-9a-zA-Z’ ‘\n’ < example.txt tr –c ‘[:alpha:]’ ‘\n’ < example.txt tr –d ‘\15\32’ < example.txt tr ‘\r\n’ ‘ ‘ < example.txt tr –s ‘[:alpha:]’ < testtext.txt 30 April 2007 SS07 – Res4CompLingsts – unix /30
sed – stream editor sed G example.txt sed 3q example.txt sed –n ‘/ regexp /p’ example.txt sed s/New\ York/Saarbruecken/ example.txt http://www.student.northpark.edu/pemente/sed/sed1line.txt 30 April 2007 SS07 – Res4CompLingsts – unix /30
awk – scanning for patterns, filtering, formatting awk ‘{ print $1}’ example.txt awk ‘$4~/in/ { print $1}’ example.txt awk ‘$4~/in$/ { print $1}’ example.txt awk ‘/New\ York/ {getline;print}’ example.txt awk NF http://www.student.northpark.edu/pemente/sed/sed1line.txt 30 April 2007 SS07 – Res4CompLingsts – unix /30
Recommend
More recommend