Javier Barroso <javibarr...@gmail.com> writes: >On Thu, Sep 10, 2009 at 11:33 PM, Cameron Hutchison <li...@xdna.net> wrote: >> >> /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 Well, no that does not handle the case where there are spaces separating the fields. This was the case with one process in particular on my system. If gawk is installed I could do gawk -F '[ \000]' '{print $1; exit}' But that doesn't work with mawk, which is the default awk on Debian: $ awk -F '[ \000]' '{print $1}' < /proc/1663/cmdline awk: line 0: regular expression compile failed (bad class -- [], [^] or [) -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org