Re: Trick at the end of "man 5 proc" doesn't work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Alexander E. Patrakov:

> Hello.
>
> man 5 proc says:
>
>> NOTES
>>        Many strings (i.e., the environment and command line) are in
>> the internal format, with subfields terminated by null bytes ('\0'),
>> so you may find that things are more readable if you use od -c or tr
>> "\000" "\n" to read them.  Alternatively, echo `cat <file>` works
>> well.
>
> Unfortunately, echo `cat <file>` does not actually work:
>
> $ echo `cat /proc/$$/environ`
> bash: warning: command substitution: ignored null byte in input
> LC_MESSAGES=en_US.UTF-8XDG_SEAT_PATH=...
> (note that the null byte before XDG_SEAT_PATH has been just removed
> without any substitution)

Huh.  I'm surprised that it ever worked.  This appears to do the job:

  xargs -0 -n 1 < /proc/$$/environ 

It runs echo under the covers, but I think the echo command line
syntax is such that at most, you will get no output for an "-n"
environment entry.



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux