Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

13
  • 6
    this is far neat-er solution than POSIXLY_CORRECT=1 set and it is also worthy of mention that declare is alias (in that context) for typeset, another bash builtin.
    – user359096
    Commented Feb 7, 2018 at 16:50
  • 5
    This is the correct answer. Commented Jul 26, 2019 at 19:11
  • 3
    I think this is what most people are looking for. Commented Oct 18, 2019 at 23:56
  • 5
    @maoizm If you want only the variable names and nothing else, it's easier to use compgen for that. compgen -e.
    – geirha
    Commented Feb 3, 2020 at 20:33
  • 1
    @ColinFraizer try compgen -v instead
    – geirha
    Commented May 20, 2020 at 6:32