This will search for X only in variable names and only output the corresponding variable names:
set | grep -oP '^\w*X\w*(?==)'
or to simplify editing the desired template
set | grep -oP '^\w*(?==)' | grep X
or simply (perhaps more easily remembered)
set | cut -d= -f1 | grep X
If you want to combine X inside variable names, but output in the form name = value, then:
set | grep -P '^\w*X\w*(?==)'
and if you want to combine X inside variable names, but output only the value, then:
set | grep -P '^\w*X\w*(?==)' | grep -oP '(?<==).*'
anandi Jan 13 '13 at 16:34 2013-01-13 16:34
source share