mirror of
https://github.com/dunwu/linux-tutorial.git
synced 2024-04-15 19:55:24 +08:00
16 lines
372 B
Bash
16 lines
372 B
Bash
#!/usr/bin/env bash
|
||
|
||
# testing STDERR messages
|
||
# redirecting all to a file
|
||
|
||
# 脚本执行期间,用exec命令告诉shell重定向某个特定文件描述符
|
||
exec 2> test
|
||
|
||
ls badtest
|
||
echo "This is test of redirecting all output"
|
||
echo "from a script to another file"
|
||
|
||
exec 1> test1
|
||
echo "This is the end of the script"
|
||
echo "but this should go to the testerror file" >&2
|