Guest User

Untitled

a guest
May 27th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. # Prefix stdout/stderr with a static prefix.
  2. #
  3. # e.g:
  4. # $ static_prefix "[Hi there] " ls /
  5. # [Hi there] bin
  6. # [Hi there] boot
  7. # ...
  8. # [Hi there] vmlinuz
  9.  
  10. static_prefix() {
  11. local PREFIX
  12. local COMMAND
  13.  
  14. PREFIX=$1
  15. COMMAND=${@:2}
  16.  
  17. $COMMAND \
  18. 1> >(sed >&1 "s#^#$PREFIX#") \
  19. 2> >(sed >&2 "s#^#$PREFIX#")
  20. }
Add Comment
Please, Sign In to add comment