Skip to content

Instantly share code, notes, and snippets.

@julianthome
Created September 18, 2016 14:23
Show Gist options
  • Save julianthome/1a4796b32daaea7933078897fe65d4d2 to your computer and use it in GitHub Desktop.
Save julianthome/1a4796b32daaea7933078897fe65d4d2 to your computer and use it in GitHub Desktop.
Check correctness of pathname
#!/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