Created
January 26, 2023 16:56
-
-
Save chrissound/762667fba754dc1a472a6386cca124f0 to your computer and use it in GitHub Desktop.
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/sh | |
string="abc\nxyz" | |
case $string in | |
(*[[:blank:]]*) echo "string contains at least one character classified as blank";; | |
(*[[:space:]]*) echo "string contains at least one character classified as whitespace (but not blank)";; | |
(*) echo no character classified as whitespace;; | |
esac | |
if [[ "$string" =~ [[:blank:]] ]]; then echo "Contains whitespace"; else echo "Doesn't contain whitespace"; fi | |
# the above outputs: | |
# no character classified as whitespace | |
# Doesn't contain whitespace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment