Created
May 20, 2016 04:38
-
-
Save remino/c7ca952e6b18b581f5cab1721eb28d76 to your computer and use it in GitHub Desktop.
wsort: Sort a single line of words
This file contains 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/sh | |
# wsort | |
# Sort a single line of words | |
# | |
# Usage: | |
# wsort [words...] | |
# echo words | wsort | |
# | |
# Examples: | |
# wsort grape coconut apple | |
# => apple coconut grape | |
# echo foo bar | wsort | |
# => bar foo | |
# echo tokyo | wsort montreal | |
# => montreal tokyo | |
wsort() { | |
read WORDS | |
WORDS="$WORDS $@" | |
echo $WORDS | xargs -n1 | sort | xargs | |
} | |
wsort $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment