Change the of the output in lsof in linux

2k views Asked by At

I would like to obtain different result with lsof, I mean just want to show some columns, is it possible?

COMMAND     PID       USER   FD      TYPE             DEVICE  SIZE/OFF       NODE NAME
init          1       root  cwd       DIR                8,1      4096          2 /
init          1       root  rtd       DIR                8,1      4096          2 /
init          1       root  txt       REG                8,1     36992     139325 /sbin/init
init          1       root  mem       REG                8,1     14696     190970 /lib/libdl-2.11.3.so
init          1       root  mem       REG                8,1   1437064     190958 /lib/libc-2.11.3.so
1

There are 1 answers

0
vahid abdi On BEST ANSWER

Use awk:

lsof  | awk '{print $1,$2}'

this will print only column 1 and 2