Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [[ -t 0 ]]; then
  4. echo "No stdin"
  5. else
  6. echo "Got stdin"
  7. while read input; do
  8. echo $input
  9. done
  10. fi
  11.  
  12. echo "Press enter to exit"
  13. read
  14.  
  15. $ echo text | ./script
  16. Got stdin
  17. text
  18. Press enter to exit
  19. $
  20.  
  21. $ ./script
  22. No stdin
  23. Press enter to exit
  24. stops here
  25. $
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement