Created
July 24, 2018 14:38
-
-
Save wdzajicek/150ead3f48be74d8c89b3b3a431cd093 to your computer and use it in GitHub Desktop.
Have Terminal Echo Characters That Must Be Escaped
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 | |
# Save this code as 'bashreg.sh' and run it in terminal `$ sh bashreg.sh` | |
special=$'`!@#$%^&*()-_+={}|[]\\;\':",.<>?/ ' | |
for ((i=0; i < ${#special}; i++)); do | |
char="${special:i:1}" | |
printf -v q_char '%q' "$char" | |
if [[ "$char" != "$q_char" ]]; then | |
printf 'Yes - character %s needs to be escaped\n' "$char" | |
else | |
printf 'No - character %s does not need to be escaped\n' "$char" | |
fi | |
done | sort |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment