linux-tutorial/codes/shell/输入和输出/创建自己的重定向/关闭文件描述符.sh
2019-10-29 18:22:19 +08:00

18 lines
251 B
Bash

#!/usr/bin/env 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