In Bash, it is possible to do string manipulation on a variable, for example to get the current runlevel on a Linux machine:
current_runlevel=$(runlevel) #sample output: 'N 2'
current_runlevel=${current_runlevel#* }
echo $current_runlevel #sample output: '2'
However, is it possible to combine the two lines, so no intermediate variable is required? Using the same example, I want it to look something like:
current_runlevel=${$(runlevel)#* }
This does not work, giving the error
${$(runlevel)#* }: bad substitution
Any ideas on how it might be possible to use a literal string in Bash string manipulation expressions?
echo ${$(echo foo)#f} -> oo