Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [[ -t 0 ]]; then
- echo "No stdin"
- else
- echo "Got stdin"
- while read input; do
- echo $input
- done
- fi
- echo "Press enter to exit"
- read
- $ echo text | ./script
- Got stdin
- text
- Press enter to exit
- $
- $ ./script
- No stdin
- Press enter to exit
- stops here
- $
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement