Thursday, April 14, 2011

More useful Unix one line scripts

Goal: Take the 9th column of the document and count all of the lines that  have a semicolon.
cat document.txt | cut -f9 | egrep ';' | wc -l

Goal: count the number of columns in a text.
head -1 document.txt | awk '{print NF}'

No comments:

Post a Comment