I want to export some environment variables which I set in a dash script to a file:
myvariable="line 1 LINE=3 some characters: # \" \$ line 5" myvariable2="abc" export myvariable myvariable2
expected result (a usable script):
declare -x myvariable="line 1 LINE=3 some characters: # \" \$ line 5" declare -x myvariable2="abc"
The result is what I get using the
export command. But it exports all envvars and doesn't allow filtering. Because of the multi-line character of the variable,
greping the result is not possible.
In contrast, the
printenv command allow to output only a selection of variables, but it doesn't care about escaping and it doesn't output the variable names in this use case.