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?
To cut (
and anything after it you have match exactly that.
echo "${toto%(*}"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.