reassign-stdout.sh
来自「Shall高级编程」· Shell 代码 · 共 38 行
SH
38 行
#!/bin/bash# reassign-stdout.shLOGFILE=logfile.txtexec 6>&1 # Link file descriptor #6 with stdout. # Saves stdout.exec > $LOGFILE # stdout replaced with file "logfile.txt".# ----------------------------------------------------------- ## All output from commands in this block sent to file $LOGFILE.echo -n "Logfile: "dateecho "-------------------------------------"echoecho "Output of \"ls -al\" command"echols -alecho; echoecho "Output of \"df\" command"echodf# ----------------------------------------------------------- #exec 1>&6 6>&- # Restore stdout and close file descriptor #6.echoecho "== stdout now restored to default == "echols -alechoexit 0
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?