The string of example is:
abcdefghijklmno
If I give in input:
abc FALSE #at least 4 characters.
abcd TRUE
cdefg FALSE #because the match must start from the first character.
abcde TRUE
abcdeghi FALSE #because the characters must be contained consecutively.
abcdefgh TRUE
abcdefghi TRUE
abcdefghijklmno TRUE
abcdefghijklmnop FALSE #because it exceeds the example string.
i have tried:
set -- abc
i=1
[[ abcdefghijklmno == ${!i}* ]]
echo $?
but echo "$?" returns 0 also with 3, 2, 1 or 0 characters.
This other code is obviously wrong but it is to communicate what I would like to do:
set -- abc
i=1
[[ abcdefghijklmno == ${!i}{4}* ]]
echo $?
EDIT:
The solution that suits me is the following:
set -- abc
i=1
[[ abcdefghijklmno == ${!i}* && $(expr length "${!i}") -ge 4 ]]
echo $?