shell/理解输入和输出/永久重定向.sh

15 lines
361 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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