Given the following string:
toto="function(param"
I want to get the substring function
from the string above, in bash.
I tried the following:
echo "${toto%(}"
Which gives:
function(param
However, with this example:
echo "${toto%param}"
I get:
function(
As expected.
The expansion did not take place when expanding the the character "(".
Why is that ? How can I extract only the beginning (before the "(" of this string ?
CodePudding user response:
To cut (
and anything after it you have match exactly that.
echo "${toto%(*}"