I'm trying to check if a variable'd string is only one character and use that in an if statement the only way I could find is:
$expr "${var}" : . # expr STRING : regrep
where the "." is the grep wildcard for any single character.
Whats wrong with my code here and is there a better way to check if the input is 1 character?
also if i want to pass a variable into a arguement of another function like expr but the content of the variable might cause a syntax error if treat as other then a string, how do i escape ("\") the contents of the variable and not the variable call itself.
---------- Post updated at 06:32 PM ---------- Previous update was at 06:21 PM ----------
also if i want to pass a variable into a arguement of another function like expr but the content of the variable might cause a syntax error if treat as other then a string, how do i escape ("\") the contents of the variable and not the variable call itself.