如果我得到正确的问题,您可以尝试以下方式:
#!/bin/sh if [ -t 0 ]; then echo running interactivelly else while read -r line ; do echo $line done fi