I'm reviewing an old shell script. I'm not able to understand two things in it.
rm /data/log || true
value=$(cat /datafile)
if [ ${value: -1} == 0 ]
then echo 'do'
else echo 'dont'
fi
value: -1- What is this actually doing?rm /data/log || true- What this||truedoing?
${var:-default}is a Bourne and standardshoperator (from the 70s), while${var:offset:length}is a ksh93 operator (from the 90s, now also supported by bash, zsh, mksh and busybox sh with variations, but not standard). – Stéphane Chazelas Sep 25 '20 at 06:54one character from the end of the string– TheDataGuy Oct 18 '20 at 09:59