Advertisement
peetaur

annoying bash newline handling

Aug 2nd, 2012
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.42 KB | None | 0 0
  1.  
  2. testit() {
  3.     lines=$(cat<<EOF
  4.     line1
  5.     line2
  6.     line3
  7. EOF
  8.     )
  9.  
  10.     echo "echo only"
  11.     cat <(echo $lines)
  12.     echo
  13.  
  14.     echo "cat anonymous pipe"
  15.     cat <(echo $lines)
  16.     echo
  17.  
  18.     echo "hack loop and pipe"
  19.     cat <(for line in $(echo $lines); do echo $line; done)
  20. }
  21.  
  22. testit
  23.  
  24.  
  25.  
  26.  
  27. echo only
  28. line1 line2 line3
  29.  
  30. cat anonymous pipe
  31. line1 line2 line3
  32.  
  33. hack loop and pipe
  34. line1
  35. line2
  36. line3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement