Skip to main content
Tweeted twitter.com/StackUnix/status/1104260680037945345
Question Protected by Kusalananda

I would like to delete the last character of a string, I tried this little script :

#! /bin/sh 

t="lkj"
t=${t:-2}
echo $t

but it prints "lkj", what I am doing wrong? Thank you in advance!

I would like to delete the last character of a string, I tried this little script :

#! /bin/sh 

t="lkj"
t=${t:-2}
echo $t

but it prints "lkj", what I am doing wrong? Thank you in advance!

I would like to delete the last character of a string, I tried this little script :

#! /bin/sh 

t="lkj"
t=${t:-2}
echo $t

but it prints "lkj", what I am doing wrong?

Delete the last character of a string using string manipulation in shell script

Source Link
user3581976
  • 3.2k
  • 3
  • 20
  • 19

string manipulation in shell script

I would like to delete the last character of a string, I tried this little script :

#! /bin/sh 

t="lkj"
t=${t:-2}
echo $t

but it prints "lkj", what I am doing wrong? Thank you in advance!