jeudi 3 août 2017

simple bash strings contains compression is not working

I'm sure there's probably a syntax mistake but I have looked and that's the way others seems to write it (here) Can anyone please tell me why the following is happening-

h="23538_"
if [[ "$h" == "23538_" ]]; then echo "true"; else echo "false"; fi;
>> true
if [[ *"$h"* == "23538_" ]]; then echo "true"; else echo "false"; fi;
>> false

Also tried:

h=23538
if [[ *"$h"* == "23538_" ]]; then echo "true"; else echo "false"; fi;
 >> false

if [[ *$h* == "23538_" ]]; then echo "true"; else echo "false"; fi;
>> false

if [[ *{$h}* == "23538_" ]]; then echo "true"; else echo "false"; fi
>> false

h='_23538__'
if [[ *"$h"* == "23538_" ]]; then echo "true"; else echo "false"; fi

In a few words - I am trying to find if $h is a sub-string of "23538_" string.

Hope someone could help me...:)

Aucun commentaire:

Enregistrer un commentaire