Sample Header Ad - 728x90

How do I source another process's environment variables?

32 votes
11 answers
11627 views
If I examine /proc/1/environ I can see a null-byte-delimited string of process 1's environment variables. I'd like to bring these variables into my current environment. Is there an easy way to do this? The proc man page gives me a snippet which helps be print out each environment variable on a line-by-line basis (cat /proc/1/environ; echo) | tr '\000' '\n'. This helps me verify the contents are correct, but what I really need to do is source these variables into my current bash session. How do I do that?
Asked by Dane O'Connor (451 rep)
Apr 16, 2014, 07:54 PM
Last activity: Mar 28, 2025, 09:29 AM