Created
July 4, 2019 13:03
-
-
Save marcelomgarcia/8d0677dc42f1537f2dda64701790f1ed to your computer and use it in GitHub Desktop.
Split variables in format "WWxHH" "WW" and "HH" (width and height) in Bash.
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
#!/usr/bin/env bash | |
# Split the values passed as wwwXhhh in width and height | |
# | |
function wh_vals { | |
# Convert upper 'X' to lower 'x' so the 'cut' command works. | |
size="$(tr '[:upper:]' '[:lower:]' <<<"$1")" | |
width="$(cut -d'x' -f1 <<<"$size")" | |
height="$(cut -d'x' -f2 <<<"$size")" | |
} | |
mysize="$1" | |
wh_vals $mysize | |
echo $width | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment