This is how my input string looks like:
INPUT_STRING="{/p1/p2=grabthistext}"
I want to print grabthistext
from the INPUT_STRING
.
I tried echo "${INPUT_STRING##*=}"
which prints grabthistext}
How do I read only grabthistext
using parameter expansion expression?
If you really want a single parameter expansion then you can use:
#!/bin/bash
shopt -s extglob
INPUT_STRING="{/p1/p2=grabthistext}"
echo "${INPUT_STRING//@(*=|\})}"
grabthistext
I would use a bash regex though:
#!/bin/bash
INPUT_STRING="{/p1/p2=grabthistext}"
[[ $INPUT_STRING =~ =(.*)} ]] && echo "${BASH_REMATCH[1]}"
grabthistext