On Thu, Sep 10, 2009 at 11:33 PM, Cameron Hutchison <li...@xdna.net> wrote: > Javier Barroso <javibarr...@gmail.com> writes: > >>> is this "xargs: echo: terminated by signal 13" the output it should be? >>Probably, substituting: > >> bin=$(xargs -n 1 -0 echo < /proc/$pid/cmdline | awk '{print $1 ; exit}') > >>with > >>bin=$(awk '{print $1; exit}' /proc/$pid/cmdline) > >>will solved the issue > >>But I'm not sure why Cameron used xargs in this case. > > /proc/pid/cmdline usually has ASCII NUL separated fields, which awk does > not split, so usually you have to use xargs -0. I noticed some cases > where the args were space separated (perl script), so I needed awk for > that case. I'll look more into awk and see if it can handle NULs in > some way. It doesn't by default. Ok, I didn't know that. Thank you for the explication
awk -F '\000' '{print $1;exit}' /proc/$pid/cmdline do the trick then Regards, -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org