linux-tutorial/codes/shell/示例脚本/输入和输出/在脚本中使用重定向输入.sh
2019-05-10 11:17:57 +08:00

13 lines
196 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# redirecting the inpiut
# 从test中读取数据而不是从STDIN中读取数据
exec 0< test
count=1
while read line
do
echo "Line #$count : $line "
count=$[ $count +1 ]
done