Skip to content

Instantly share code, notes, and snippets.

@donaldducky
Created December 5, 2012 16:20
Show Gist options
  • Select an option

  • Save donaldducky/4217082 to your computer and use it in GitHub Desktop.

Select an option

Save donaldducky/4217082 to your computer and use it in GitHub Desktop.
Cut Sort Uniq
#!/bin/bash
# simple script to cut / sort / uniq
# ie.
# a.txt: a3wr
# z.txt: wra3
# s.txt: a3r2
# a.txt: a;kljf
# m.json: adf
#
# becomes:
# a.txt
# m.json
# s.txt
# z.txt
function cut_sort_uniq() {
DELIMITER=":"
POSITION=1
if [ $1 ]; then
DELIMITER="$1"
fi
if [ $2 ]; then
POSITION=$2
fi
#echo cut -d $DELIMITER -f $POSITION | sort | uniq
cut -d $DELIMITER -f $POSITION | sort | uniq
}
cut_sort_uniq "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment