Skip to content

Instantly share code, notes, and snippets.

@jeffreyiacono
Created September 6, 2012 02:29
Show Gist options
  • Save jeffreyiacono/3650118 to your computer and use it in GitHub Desktop.
Save jeffreyiacono/3650118 to your computer and use it in GitHub Desktop.
fun with unix programs
$ cat sample | sort | uniq -c
2 bat
4 cat
2 dog
1 gator
$ cat sample | sort | uniq -c | sed "s/^[ \t]*//"
2 bat
4 cat
2 dog
1 gator
$ cat sample | sort | uniq -c | sed "s/^[ \t]*//" | cut -d " " -f1
2
4
2
1
$ cat sample | sort | uniq -c | sed "s/^[ \t]*//" | cut -d " " -f2
bat
cat
dog
gator
$ cat sample | sort | uniq -c | sed "s/^[ \t]*//" | cut -d " " -f1,2
2 bat
4 cat
2 dog
1 gator
$ cat sample | sort | uniq -c | sed "s/^[ \t]*//" | sort -n -r
4 cat
2 dog
2 bat
1 gator
cat
dog
cat
bat
cat
cat
gator
dog
bat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment