linux-tutorial/codes/shell/示例脚本/输入和输出/在脚本中使用重定向输入.sh

14 lines
204 B
Bash
Raw Normal View History

2019-05-10 11:17:57 +08:00
#!/bin/bash
2019-10-10 08:56:31 +08:00
2019-05-10 11:17:57 +08:00
# redirecting the inpiut
# 从test中读取数据而不是从STDIN中读取数据
exec 0< test
count=1
while read line
do
2019-10-10 08:56:31 +08:00
echo "Line #$count : $line "
count=$[ $count + 1 ]
2019-05-10 11:17:57 +08:00
done