from this answer: Using a command inside a sed substitution there is used this to make command substitution:
echo aaabbdd | sed -e 's/a*/echo `echo -n & | wc -m`/;e'
When I shell use double quotes to expand bash commands (as suggested in comments: sed '$a'"$(some commands)" somefile and when to use embedded commands in sed (as from the example above - from the link) - because I can obviously use & (sed match) in outer bash command. So which use when?
&is not placing theechocommand in the background - it's substituted by the matched portion (in this case,aaa) before the pattern space is passed to the shell for executionsed '$a'"$(alias so)"however, any escape sequences like\tin the content of the command output will get expanded, and you cannot have literal newlines in that outputsubstituted by the matched portion, from when does&substitute any portion and which portion? From preceding command? I do no understand. give some exmaple used in bash-ioption with thataliasexample, you do not needsedat all,alias so >> filenamewill append the output of the command to the filesedwith bash commands. Can you still explain the '&' ? Is it just sed substitution or is it bash feature?