This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

How would you represent EOF in bash

By: a guest on Feb 26th, 2012  |  syntax: None  |  size: 0.42 KB  |  views: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. read -d EOF stdin
  2.  
  3. for word in $stdin; do stuff; done
  4.        
  5. stdin=$(cat)
  6. for word in $stdin; do stuff; done
  7.        
  8. while read -r -a array; do
  9.     for word in "${array[@]}"; do
  10.         stuff;
  11.     done
  12. done
  13.        
  14. if test "$char" = '^V'; then...
  15.        
  16. $ cat | od -b
  17. ^D
  18. 0000000 004 012
  19. 0000002
  20.        
  21. $ read -d "$(echo -e '04')" stdin
  22. foo
  23. bar quuz^Hx
  24. ^D
  25. $ echo "$stdin"
  26. foo
  27. bar quux
  28. $ for word in $stdin; do echo $word; done
  29. foo
  30. bar
  31. quux
clone this paste RAW Paste Data