Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I remove a substring of a string in a shell script?

I have a file with a list of words like:

FIRST_WORD abc
FIRST_WORD(1) bcd
FIRST_WORD(2) def
SECOND_WORD gh
THIRD_WORD jiu
THIRD_WORD(1) lom
...

and I want to remove the (i), when it is present, to obtain:

FIRST_WORD abc
FIRST_WORD bcd
FIRST_WORD def
SECOND_WORD gh
THIRD_WORD jiu
THIRD_WORD lom
...
like image 457
user1835630 Avatar asked Mar 07 '26 11:03

user1835630


1 Answers

You can get it:

test="123456"
echo ${test:3}

Output:

456
like image 67
arutaku Avatar answered Mar 09 '26 04:03

arutaku