Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
what have you tried so far? –  longneck Jun 10 '13 at 14:28
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.