3

The following command produced the unix domain socket opened by PID 30661

$ sudo lsof -U -a -p 30661
COMMAND   PID    USER   FD   TYPE     DEVICE SIZE/OFF       NODE NAME
haproxy 30661 haproxy    7u  unix 0xc784a000      0t0 3348210055 /var/lib/haproxy/stats.30660.tmp

I want a command using lsof internal options to give the output as just "var/lib/haproxy/stats.30660.tmp"

I don't want to use pipe and other tools to get this output.

0

1 Answer 1

5

lsof's internal formatting options are quite restrictive, in that they insist on prefixing each field with a letter designating that field's meaning. For example,

$ sudo lsof -U -a -p 30661 -Fn

would give

p30661
n/var/lib/haproxy/stats.30660.tmp

The man page says that the process ID is always selected, so there doesn't seem to be a way of only getting the filename (of which there may of course be more than one). I want to give you more options, but you said that you don't want to use pipes or other commands.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .