Created
April 23, 2017 02:26
-
-
Save tonytonyjan/af03e5607c2407b50f82d096bb69992a to your computer and use it in GitHub Desktop.
Convert any string to to lowercase and dashes fromat
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 | |
# $ dasherize Hello, world! I am tonytonyjan. | |
printf "$*" \ | |
| tr '[:upper:]' '[:lower:]' \ | |
| tr -C '[:alnum:]' ' ' \ | |
| tr -s ' ' '-' \ | |
| sed -e 's/^-*//' -e 's/-*$//' \ | |
| tr -d '\n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment