Created
September 18, 2016 14:23
-
-
Save julianthome/1a4796b32daaea7933078897fe65d4d2 to your computer and use it in GitHub Desktop.
Check correctness of pathname
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/bash | |
DELIM="/" | |
FILE="[a-zA-Z]([a-zA-Z0-9])*" | |
R="(${DELIM})?${FILE}(${DELIM}${FILE})*${DELIM}?" | |
path=$1 | |
echo "$path" | egrep -x "$R" | |
[ $? -eq 0 ] && { | |
echo "OK" | |
exit 0 | |
} | |
echo "NOK" | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment