Created
December 5, 2012 16:20
-
-
Save donaldducky/4217082 to your computer and use it in GitHub Desktop.
Cut Sort Uniq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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