In a bash script I need to compare the first char of two Strings.
To do this, I use the head operator like this:
var1="foo"
var2="doo"
headVar1=$(head -c1 $var1)
headVar2=$(head -c1 $var2)
if [ $headVar1 == $headVar2 ]
then
#miau
fi
But the console says "head: cant open foo for reading: Doesnt exist the file or directorie" And the same with doo
Some help?
Thanks.
${var1:0:1}==isn't supported in POSIX[. Bash will support it as an extension, but better to use the compliant string comparison operator=.