`echo "export" $((set -o posix ; set)|awk -F "=" 'BEGIN{ORS=" "}1 $1~/[a-zA-Z]/ {print $1}')`
First, get all set environment variables:
(set -o posix ; set)Reference: https://superuser.com/questions/420295/how-do-i-see-a-list-of-all-currently-defined-environment-variables-in-a-linux-baGet all environment variable names, separated by space:
awk -F "=" 'BEGIN{ORS=" "}1 $1~/[a-zA-Z]/ {print $1}'Reference: awk-Printing column value without new line and adding comma and http://stackoverflow.com/questions/14212993/regular-expression-to-match-a-pattern-inside-awk-commandNow, we need to export these variables, but xargs can not do this because it forks child process, export have to be run under current process.
echo "export" ...build a command we want, then use `` to run it. That's all :p.