Reputation: 189
Given a string Please help me do my homework !!!
I would like to parse it in to Please help me do my homework
using bash.
What I tried is
str="Please help me do my homework !!!"
printf "${str: -4:100}"
which I get !!!
. I guess ${str: -4} means it starts from 4th character from the last.
Upvotes: 1
Views: 68
Reputation: 88889
With GNU bash and its Parameter Expansion:
str='Please help me do my homework !!!'
echo "${str:0: -4}"
Output:
Please help me do my homework
Upvotes: 3