1

I tried with

lsof -F c somefile

But I get

p1
cinit
p231
cmountall
p314
cupstart-udev-br
p317
cudevd

Instead of

init
mountall
...

Any way to get just the command?

  • idk what do you mean by that – kittie Aug 6 '14 at 14:13
0

Man page says procces ID is always selected.

depending on your need, you may use awk to filter out process

lsof -F c somefile | awk '/^c/ { print substr($0,2)}' 
3

This will select lines that begin with the c tag and print them out after removing the tag.

lsof -F c somefile | sed -n 's/^c//p'
  • 1
    I undeleted this since it is a perfectly good answer and indeed much simpler than using awk. If you really want to remove it I promise I won't undelete again but please leave it. – terdon Aug 6 '14 at 15:25
  • I deleted my answer because I saw it was a dup of a comment (by @Stéphane Chazelas , I think) and wanted to let the commenter post it as an answer. – Mark Plotnick Aug 6 '14 at 16:38
  • Answers posted as comments are fair game. If you want to be polite, you can mention the comment but it is perfectly fine to post as an answer something that someone else posted as a comment. Especially if you flesh it out a bit as you have done. – terdon Aug 8 '14 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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