Sed

Hello all,

Just been looking into forum but couldn't find what I am looking for. I need to extract the content from a file that is between { } from any of these strings.

${C123QHOME}
${C12QHOME}

Or anything else between { } and drop that to a variable. I know that sed would do it but just can't start... any help?

So let's say ${C124HOME} would become C124HOME into a variable and then

echo MYVAR
C124HOME

Something like this ?
cat wdm
${C124HOME} would become C124HOME into a variable and then

VAR=$(sed 's/${\(..*\)}..*/\1/' wdm)
echo $VAR
C124HOME

What do you want it do to if there are multiple substitutions on the same input line - such as

${ONE} is much less that ${TWO}

If you have the name in a variable, use shell parameter expansion:

var='${C123QHOME}'
temp=${var#*{}
newvar=${temp%\}*}

If you have many lines in a file, use sed:

var=$( sed -e 's/.*{//' -e 's/}.*//' FILENAME )

With awk,

echo "\${C123QHOME}" | awk -F"{|}" '{ print $2 }'