在脚本中使用重定向输入.sh Shell 脚本

Shell 片段 · codes/shell/输入和输出/在脚本中使用重定向输入.sh · 14 行

源码

#!/usr/bin/env bash

# redirecting the inpiut

# 从test中读取数据,而不是从STDIN中读取数据
exec 0< test
count=1
while read line
do
	echo "Line #$count : $line "
	count=$[ $count + 1 ]
done

查看上游源码 ↗

内容与示例整理自 dunwu/linux-tutorial,遵循 CC BY-SA 4.0;本站保留原作者署名与许可,命令仅供学习,执行前请核对目标环境。