Skip to content

Instantly share code, notes, and snippets.

@skunkie
Created October 14, 2015 12:22
Show Gist options
  • Save skunkie/9d66f0030c3771081b35 to your computer and use it in GitHub Desktop.
Save skunkie/9d66f0030c3771081b35 to your computer and use it in GitHub Desktop.
find non-ASCII characters in a string
#!/bin/sh
usage(){
echo "
find non-ASCII characters in a string
Usage: $0 STRING
"
exit 0
}
if [ "$#" -ne 1 ]; then
usage
fi
array=$(echo "$1" | grep -o .)
for char in $array; do
if [ $(printf '%d' "'$char") -gt 127 ]; then
echo $char
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment