I need to have ha validity test to see if input from a user is valid. I need to know if the user writes a valid hex color.
Input could be “FFTTAA” which would not be valid as TT is not hex. It then need to abort so it is not written to the file. My problem is that i do not know how to single out hex as it is both letters and numbers. Which means a simple [0-9] would not work.
read -p "Use light, normal or bold (ex. light): " ANS1; read -p "Write size in mm (ex. 1.8): " ANS2; read -p "Write color in hexadecimal (ex. FFFFFF): " ANS3;
sed -i '/SwipeLauncherButtonStyle {/,/text/c\
SwipeLauncherButtonStyle {\
font: \$FONT_FAMILY '"$ANS1"' '"$ANS2"'mm;\
text-color: \#'"$ANS3"';' file.css
Instead of
[0-9], use either[0-9A-F](to allow only uppercase) or[0-9A-Fa-f](to allow lowercase as well). For example: