hello
just want to ask how you do this?
a="b=abc def ghi"
c=<all the strings after b=>
echo $c
output will be
abc def ghi
thanks!!
hello
just want to ask how you do this?
a="b=abc def ghi"
c=<all the strings after b=>
echo $c
output will be
abc def ghi
thanks!!
In Kshell or bash:
c="${a#b=}"
The syntax ${varname#pattern} causes the shortest matching pattern from the beginning of the contents of varname to be removed. In this case the pattern is the string 'b=' which is removed.
If you need to be more generic, and remove the first two characters, then either of these will work:
c="${a#??}"
c="${a:2}"
The first is the same as the previous example, except the pattern is any two characters and not a specific string. The 'a:2' indicates that the contents of variable a, starting with the second position (0 based) are to be substituted.
should you need everything before the equal sign, a variable number of characters, then this will work:
c="${a#*=}"
as the pattern is any number of characters before the equal sign.
You might want to have a read through this, or some other Kshell or bash doc:
man/man1/ksh.html man page