创建输入文件描述符

5年以前  |  阅读数:515 次  |  编程语言:Shell 
#!/bin/bash
# redirecting input file descriptors

exec 3>&1
echo "This is the 3 file descriptor" >&3

exec 6>&0
exec 0<test

count=1
while read line
do
    echo "Line #$count: $line"
    count=$[ $count+1 ]
done
exec 0<&6
read -p "Are you done now?" answer
case $answer in
Y|y) echo "Goodbye";;
N|n) echo "Sorry, this is the end";;
esac

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8