Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ ps -ef | grep "File.pdf"
- c0rp 22291 22235 12 12:21 ? 00:00:02 /usr/bin/evince /home/c0rp/File.pdf
- $ ps -ef | grep "evince"
- c0rp 22291 22235 12 12:21 ? 00:00:02 /usr/bin/evince /home/c0rp/File.pdf
- $ lsof -F +p 22291
- some other files opened
- .
- .
- .
- n/home/c0rp/File.pdf
- $ lsof -Fn +p 22291 | grep -i -E "*.pdf$" | sed s/^n//g
- /home/c0rp/File.pdf
- OUTPUT FOR OTHER PROGRAMS
- When the -F option is specified, lsof produces output that is suitable
- for processing by another program - e.g, an awk or Perl script, or a C
- program.
- ...
- ...
- These are the fields that lsof will produce. The single character
- listed first is the field identifier.
- ...
- ...
- n file name, comment, Internet address
- ...
- ...
- $ for ip in $(pgrep -x evince); do lsof -F +p $ip | grep -oP '^nK.*.pdf$'; done
- /home/terdon/file1.pdf
- /home/terdon/file2.pdf
- $ ps -ef | grep emacs
- terdon 6647 6424 23 16:26 pts/14 00:00:02 emacs
- terdon 6813 6424 0 16:26 pts/14 00:00:00 grep --color emacs
- $ pgrep emacs
- 6647
- $ pgrep -l evince
- 4606 evince
- 4611 evinced
- 4613 evince
- $ pgrep -lx evince
- 4606 evince
- 4613 evince
- ps -ef | grep evince | sed -n '/.*.pdf/p' | sed 's/.*evince (.*)$/1/g'
- $ ps -ef | grep evince | sed -n '/.*.pdf/p' | sed 's/.*evince (.*)$/1/g'
- /media/avinash/C68C57908C5779BF/pdf/PHP/PHP-Manual.pdf
- /media/avinash/C68C57908C5779BF/pdf/python.pdf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement