How to remove the last character of a string variable in ksh?

I have a string variable and I want to delete the last character.

For example: go from "testing1" to "testing".

How can I do this in KSH?

+5
source share
1 answer
var="testing1"
print ${var%?}

Output

testing

${var%?} - . "%" , . char '1' ( ). wild-card char '?' . "*" char , "", , echo ${var%i*} test. "%%" '#' '##', .

, .

+12

All Articles