Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. (d+)%s*/$
  2.  
  3. # df
  4. Filesystem 1K-blocks Used Available Use% Mounted on
  5. /dev/xvda 15997904 2404540 12943248 16% /
  6. tmpfs 252456 0 252456 0% /lib/init/rw
  7. tmpfs 252456 36 252420 1% /dev/shm
  8.  
  9. df | awk 'NR > 1 {print $5, $6;}'
  10.  
  11. 65% /
  12. 1% /dev
  13. 1% /dev/shm
  14.  
  15. df | awk 'NR > 1 {print $5;}' | tr -d '%'
  16.  
  17. df | awk '//dev/shm$/ {print $5;}' | tr -d '%'
  18.  
  19. df | awk '//$/ {print $5;}' | tr -d '%'
  20.  
  21. df -h | egrep --only-matching '[[:digit:]]+%' | tr -d '%'
  22.  
  23. import subprocess
  24. import re
  25. print re.search('(d+)% /', subprocess.Popen(["df"], stdout=subprocess.PIPE).communicate()[0]).group(1)
  26.  
  27. #!/usr/bin/env python
  28. # -*- coding: utf-8 -*-
  29.  
  30. import subprocess
  31. import re
  32.  
  33. p = subprocess.Popen(["df"], stdout=subprocess.PIPE)
  34. for line in p.stdout:
  35. usage = re.search('(d+)% /', line.rstrip())
  36. if usage != None:
  37. print usage.group(1)
  38.  
  39. df --output=pcent,target
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement