As far I know, there are 3 ways to see exported variables:
$ export -p | wc -l 50 $ env | wc -l 51 $ printenv | wc -l 51
As you can see,
export -p misses single variable. It's a
$ diff <(export -p |sed 's/declare -x //' | sed 's/"//g' | sort) <(printenv | sort) 41a42 > _=/usr/bin/printenv
$_ is special variable set to final argument of previous command executed. Why
export -p doesn't include it, unlike two other commands?
I understand that exporting
$_ might not have any sense but if
$_ is not exported then why it appears in
printenv prints environment variables, environment variables are exported ones,
$_ is not exported. Am I missing something here?