Guest User

Untitled

a guest
Jun 23rd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. Trick The First: filtering ps
  2. ------------------------------------------------------------------------
  3.  
  4. So you know how ps piped to grep shows you the grep command?
  5.  
  6. $ ps auxww | grep bash
  7. ben 64291 0.0 0.0 2435036 372 s001 R+ 11:48AM 0:00.00 grep bash
  8. ben 61887 0.0 0.0 2435468 1896 s001 S 11:38AM 0:00.13 -bash
  9. ben 61376 0.0 0.0 2435468 1888 s000 S+ 10:46AM 0:00.06 -bash
  10.  
  11. I don't understand why, but if you wrap the first character of your grep
  12. in a character class, that doesn't happen:
  13.  
  14. $ ps auxww | grep [b]ash
  15. ben 61887 0.2 0.0 2435468 1892 s001 S 11:38AM 0:00.14 -bash
  16. ben 61376 0.0 0.0 2435468 1888 s000 S+ 10:46AM 0:00.06 -bash
  17.  
  18. Trick The Second: Oops, I forgot my &&
  19. ------------------------------------------------------------------------
  20.  
  21. Sometimes you start a long-running process:
  22.  
  23. $ ./something_long
  24.  
  25. ...and then realize that you want something else to happen after it, as
  26. though you had done:
  27.  
  28. $ ./something_long && ./something_else
  29.  
  30. ...but of course you forgot to do that at first. Try this on for size:
  31.  
  32. $ sleep 30
  33. ^Z
  34. [1]+ Stopped sleep 30
  35. $ fg && echo "done"
  36. sleep 30
  37. done
Add Comment
Please, Sign In to add comment