I am trying to write a if statement in KSH that if a string is start with abc then print something, I have written some code as below but it doesn't work.
Could someone please help me
if [[ ${name} = "abc*" ]]
then
print success
fi
I am trying to write a if statement in KSH that if a string is start with abc then print something, I have written some code as below but it doesn't work.
Could someone please help me
if [[ ${name} = "abc*" ]]
then
print success
fi
I believe you can try this if you are using bash
if [[ ${name:0:3} = "abc" ]]
then
echo success
fi
I think case is more portable:
case $name in
abc* ) echo success ;;
esac
Thank you BubbaJoe, can I use this in ksh?
---------- Post updated at 11:01 AM ---------- Previous update was at 10:59 AM ----------
Thank you radoulov
Does it work in ksh, currently my machine hasn't linux env.
Yes it works in ksh
Just to add that the snipped above works with ksh93 and mksh, it doesn't work with ksh88 and pdksh.