Reputation: 21795
I read Bash : extracting part of a string.
How could I achieve this but for all matches inside a string:
x=something
echo ${x ome}
^
what to put here to get "sthing"
Any other suggestions are appreciated.
Upvotes: 0
Views: 2817
Reputation: 5198
No, the first answer is not right. All matches are to be removed. Therefore, the answer is:
echo ${x//ome/}
(See the manual.)
Upvotes: 3
Reputation: 21795
It was too simple:
${x/ome/}
Another question that occurs to me now, is how could I put regular expressions inside the slashes but this is good for now.
Upvotes: 0