IF conditional evaluates variable into range, BASH

Another.Chemist

Good day to all,

I was wondering how to evaluate a string variable into a range, is it possible?

 S=CUESTIONARIO15 ; if [ "$S" == "${S:0:12}*[0-9][0-9]*" ] ;then echo 999 ;fi

Thanks so much in advance for any clue

that other guy

You can match against globs using [[:

S=CUESTIONARIO15
if [[ "$S" == "${S:0:12}"*[0-9][0-9]* ]]
then
  echo 999
fi

Make sure to use bash and not sh, and make sure not to quote the globbing characters in the pattern.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

JavaScript: empty array, [ ] evaluates to true in conditional structures. Why is this?

Null-conditional operator evaluates to bool not to bool? as expected

Conditional count in filtered range

Structure of Bash conditional - variable versus directory

Logical OR evaluates all expression in Bash script

Bash conditional with shell variable

Is it possible to have a variable that dynamically evaluates a command in bash?

bash if statement with strings always evaluates to true

TypeScript tuples conditional comparison always evaluates to false

What does underscore variable followed by range mean in bash: $_{0..10}

Python unittest: Unable to mock imported functions so that conditional evaluates to False

/bin/sh evaluates string while Bash does not

Line count from grep into count range variable Bash OpenWRT

Applescript variable returns right value but evaluates wrong

Is it correct to say if any non-macro variable that is used in a conditional directive evaluates to 0?

Bash -eq evaluates to true?

How to check if a variable contains a character not found in a list within a BASH conditional?

Variable always evaluates to false

Bash conditional assignment that tests a variable whilst building a string

How can I delimit a variable to be within a range of numbers in bash?

NLog layout variable evaluates blank

Conditional formatting on visible range?

why conditional or doesn't evaluates to boolean value when assigned to a variable

VLOOKUP evaluates to an out of bounds range

Conditional boost::range::join

jquery click function declaration evaluates the variable at runtime

TypeScript generic with conditional evaluates union types separately

Expand alphanumeric range from variable in bash

Bash if statement expression evaluates to FALSE but $? is 0, why?