Skip to content

Instantly share code, notes, and snippets.

View jappy's full-sized avatar

Scott Jappinen jappy

View GitHub Profile
@jappy
jappy / gist:2015447
Created March 11, 2012 07:36
unix command to sort works in a text by dictionary order
tr -sc 'A-Za-z' '\n' < filename.txt | sort | uniq | sort -d
tr 'A-Z' 'a-z' < filename.txt | tr -sc 'a-z' '\n'| sort | uniq | sort -d | less # normalizes to lowercase first
@jappy
jappy / gist:2015435
Created March 11, 2012 07:32
unix sort cheatsheet
sort –d #dictionary order
sort –f #fold case
sort –n #numeric order
sort –nr #reverse numeric order
sort +1 #start with field 1 (starting from 0)
sort +0.50 #start with 50th character
sort +1.5 #start with 5th character of field
@jappy
jappy / gist:2015427
Created March 11, 2012 07:28
unix command to count sequences of consonants in a text
tr 'a-z' 'A-Z' < filename.txt | tr -sc 'BCDFGHJKLMNPQRSTVWXYZ' '\n' | sort | uniq -c | sort -nr
@jappy
jappy / gist:2015423
Created March 11, 2012 07:26
unix command to count sequences of vowels from a text
tr 'a-z' 'A-Z' < filename.txt | tr -sc 'AEIOU' 'n' | sort | uniq -c | sort -nr
@jappy
jappy / gist:2015420
Created March 11, 2012 07:25
unix command to merge the counts for upper and lower case
tr 'a-z' 'A-Z' < filename.txt | tr -sc 'A-Z' 'n' | sort | uniq -c | sort -nr
@jappy
jappy / gist:2012442
Created March 10, 2012 18:42
unix command to extract unique words by frequency normalized by case from a file (Mac/Linux)
tr 'A-Z' 'a-z' < filename.txt | tr -sc 'a-z' '\n' | sort | uniq -c | sort -n -r
@jappy
jappy / gist:2012386
Created March 10, 2012 18:25
unix command to extract unique words by frequency from a file (Mac/Linux)
tr -sc 'A-Za-z' '\n' < filename.txt | sort | uniq -c | sort -n -r
@jappy
jappy / gist:2012357
Created March 10, 2012 18:16
unix command to extract words from a file (Mac/Linux)
tr -sc 'A-Za-z' '\n' < filename.txt
@jappy
jappy / dos2unix.sh
Created March 10, 2012 18:03
Shell script to convert files with CRLF to LF (Mac/Linux)
#! /bin/sh
for x
do
echo "Converting $x"
tr -d '\015' < "$x" > "tmp.$x"
mv "tmp.$x" "$x"
done