Useful CLI tools (bash) for Arch Linux administration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
638 B

5 years ago
  1. #!/usr/bin/env bash
  2. # specialchars - Show special characters which need to be escaped in shell
  3. # Author: codeforester
  4. # https://stackoverflow.com/questions/15783701/which-characters-need-to-be-escaped-in-bash-how-do-we-know-it/44581064#44581064
  5. #####################################
  6. special=$'`!@#$%^&*()-_+={}|[]\\;\':",.<>?/ '
  7. for ((i=0; i < ${#special}; i++)); do
  8. char="${special:i:1}"
  9. printf -v q_char '%q' "$char"
  10. if [[ "$char" != "$q_char" ]]; then
  11. printf 'Yes - character %s needs to be escaped\n' "$char"
  12. else
  13. printf 'No - character %s does not need to be escaped\n' "$char"
  14. fi
  15. done | sort