Test stdin data presence in bash


/ Published in: Bash
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #!/bin/sh
  2. if [ -t 0 ]; then
  3. echo running interactivelly
  4. else
  5. while read -r line ; do
  6. echo $line
  7. done
  8. fi

URL: http://stackoverflow.com/questions/2456750/detect-presence-of-stdin-contents-in-bourne-shell

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.