The Stack Overflow podcast is back! Listen to an interview with our new CEO.
1 of 3

How can I extract only the pid column and only the pathname column in the lsof output?

$ sudo lsof -u t  |   grep -i "\.pdf" 

evince  1788    t   37r      REG                8,4    176328     134478 /home/t/some/path1/white space/string1 + string2 string3.pdf
evince  3415    t   37r      REG                8,4    176328     134478 /home/t/some/path2/white spacestring5 string3.pdf

How can I extract only the second column (pids of processes)?

How can I extract only the ninth column (pathnames of files)? (pathnames can contain any character allowed by Linux and ext4 file systems)

Thanks.