I am learning about linux and I have a question that I have encountered in one of the books I read:
The following are two different ways to print out environment variables. Please describe their differences:
$ /usr/bin/env $ /usr/bin/strings /proc/$$/environ
I searched both in Google and in the book, and everything I found suggests that both methods prints out the environment variables of the current process, but when I try to run them, I see differences but I don't know why.
using the following commands:
/usr/bin/env > file1 /usr/bin/strings /proc/$$/environ > file2
Now I'm want to see some difference between the files, so i sort the lines and check whether a line in file1 isn't appear in file2 and vice versa
The result of
comm -13 <(sort -u file1) <(sort -u file2)
and when I use
comm -13 <(sort -u file2) <(sort -u file1)
(source for the command: Check whether all lines of file occur in different file)
xargs -0 -L1 < /proc/$$/environwill produce the same content as
env, perhaps in a different order.