I'm asked in my course HW to write a comparison in bash using just one line and without ';'. I am required to check whether the string in the variable 'fname' ends with the letter 'C', and if so to print "Match". There is no else command. how can I do it in one line?
Do you know of the &&
, ||
and &
command terminators in bash?
[[ "${fname:(-1)}" == "C" ]] && echo Match
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With