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.

Required fields*

6
  • This is almost what I want. I've been looking at help declare and trying things, but I cannot find a way to only print the exported envars. Commented May 20, 2016 at 9:41
  • the grep -- -x trick fails with multiline variables. I'm working on a way to get only the exported variable names to declare -p $(...) (cannot use xargs as declare is a builtin). I got declare -p $(env -0 | grep -zo '^\w\+=' | sed -e 's/=$//') which seems to work, although it seems little maintenance nightmare. Commented May 20, 2016 at 9:55
  • yep, see updated answer. declare -p -x, no need for grep. Commented May 20, 2016 at 9:55
  • anyway @cas your help is greatly appreciated :) Commented May 20, 2016 at 9:56
  • 1
    I dunno. "drugs" is the excuse I use :) Commented May 20, 2016 at 10:04