Advertisement
Guest User

Untitled

a guest
Aug 28th, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. $ ps -ef | grep "File.pdf"
  2. c0rp 22291 22235 12 12:21 ? 00:00:02 /usr/bin/evince /home/c0rp/File.pdf
  3.  
  4. $ ps -ef | grep "evince"
  5. c0rp 22291 22235 12 12:21 ? 00:00:02 /usr/bin/evince /home/c0rp/File.pdf
  6.  
  7. $ lsof -F +p 22291
  8. some other files opened
  9. .
  10. .
  11. .
  12. n/home/c0rp/File.pdf
  13.  
  14. $ lsof -Fn +p 22291 | grep -i -E "*.pdf$" | sed s/^n//g
  15. /home/c0rp/File.pdf
  16.  
  17. OUTPUT FOR OTHER PROGRAMS
  18. When the -F option is specified, lsof produces output that is suitable
  19. for processing by another program - e.g, an awk or Perl script, or a C
  20. program.
  21. ...
  22. ...
  23. These are the fields that lsof will produce. The single character
  24. listed first is the field identifier.
  25. ...
  26. ...
  27. n file name, comment, Internet address
  28. ...
  29. ...
  30.  
  31. $ for ip in $(pgrep -x evince); do lsof -F +p $ip | grep -oP '^nK.*.pdf$'; done
  32. /home/terdon/file1.pdf
  33. /home/terdon/file2.pdf
  34.  
  35. $ ps -ef | grep emacs
  36. terdon 6647 6424 23 16:26 pts/14 00:00:02 emacs
  37. terdon 6813 6424 0 16:26 pts/14 00:00:00 grep --color emacs
  38. $ pgrep emacs
  39. 6647
  40.  
  41. $ pgrep -l evince
  42. 4606 evince
  43. 4611 evinced
  44. 4613 evince
  45. $ pgrep -lx evince
  46. 4606 evince
  47. 4613 evince
  48.  
  49. ps -ef | grep evince | sed -n '/.*.pdf/p' | sed 's/.*evince (.*)$/1/g'
  50.  
  51. $ ps -ef | grep evince | sed -n '/.*.pdf/p' | sed 's/.*evince (.*)$/1/g'
  52. /media/avinash/C68C57908C5779BF/pdf/PHP/PHP-Manual.pdf
  53. /media/avinash/C68C57908C5779BF/pdf/python.pdf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement