Skip to main content
added 89 characters in body
Source Link
nevelis
  • 131
  • 4

This was enough for me to get a list of all exported variable names that handled quoted and multi-lined values:

export | egrep ^declare | cut -d= -f1 | cut -d' ' -f3 

As Stephane pointed out, this works in bash, and you'd be better using compgen -e which is bash-only. If you want a 1-liner that works the same in bash, dash and zsh, you can use this instead:

export | egrep '^(declare|export)' | sed -E 's/(^declare -x |export )//' | cut -d= -f1 | cut -d' ' -f2 

... although this won't work for multi-line values in dash.

This was enough for me to get a list of all exported variable names that handled quoted and multi-lined values:

export | egrep ^declare | cut -d= -f1 | cut -d' ' -f3 

As Stephane pointed out, this works in bash, and you'd be better using compgen -e which is bash-only. If you want a 1-liner that works the same in bash, dash and zsh, you can use this instead:

export | sed -E 's/(^declare -x |export )//' | cut -d= -f1 | cut -d' ' -f2 

This was enough for me to get a list of all exported variable names that handled quoted and multi-lined values:

export | egrep ^declare | cut -d= -f1 | cut -d' ' -f3 

As Stephane pointed out, this works in bash, and you'd be better using compgen -e which is bash-only. If you want a 1-liner that works the same in bash, dash and zsh, you can use this instead:

export | egrep '^(declare|export)' | sed -E 's/(^declare -x |export )//' | cut -d= -f1 | cut -d' ' -f2 

... although this won't work for multi-line values in dash.

added 279 characters in body
Source Link
nevelis
  • 131
  • 4

This was enough for me to get a list of all exported variable names that handled quoted and multi-lined values:

export | egrep ^declare | cut -d= -f1 | cut -d' ' -f3 

As Stephane pointed out, this works in bash, and you'd be better using compgen -e which is bash-only. If you want a 1-liner that works the same in bash, dash and zsh, you can use this instead:

export | sed -E 's/(^declare -x |export )//' | cut -d= -f1 | cut -d' ' -f2 

This was enough for me to get a list of all exported variable names that handled quoted and multi-lined values:

export | egrep ^declare | cut -d= -f1 | cut -d' ' -f3 

This was enough for me to get a list of all exported variable names that handled quoted and multi-lined values:

export | egrep ^declare | cut -d= -f1 | cut -d' ' -f3 

As Stephane pointed out, this works in bash, and you'd be better using compgen -e which is bash-only. If you want a 1-liner that works the same in bash, dash and zsh, you can use this instead:

export | sed -E 's/(^declare -x |export )//' | cut -d= -f1 | cut -d' ' -f2 
Source Link
nevelis
  • 131
  • 4

This was enough for me to get a list of all exported variable names that handled quoted and multi-lined values:

export | egrep ^declare | cut -d= -f1 | cut -d' ' -f3