关闭文件描述符

5年以前  |  阅读数:474 次  |  编程语言:Shell 
#!/bin/bash
# testing closing file descriptors

exec 3>test
echo "This is a test line of data" >&3

# closing file descriptor
exec 3>&-

echo "This won't work" >&3

cat test

#覆盖前一个test文件
exec 3>test
echo "This'll be bad" >&3

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8