如果我在变量中有一个 bash 字符串。我如何提取/检索除最后一个字符之外的字符串,如果我想提取到最后两个字符会有多容易?
例子:
# Removing the last character
INPUT="This is my string."
# Expected output "This is my string"
# Removing the last two characters
INPUT="This is my stringoi"
# Expected output "This is my string"