gpt4 book ai didi

shell - 展示 bash shell stdout/stderr 重定向行为的备忘单

转载 作者:行者123 更新时间:2023-12-01 00:02:59 27 4
gpt4 key购买 nike

是否有一个很好的备忘单展示了 BASH shell 重定向的许多用途?我很想把这样的东西给我的学生。我想看到的一些例子:

cmd > output_file.txt       #redirect stdout to output_file.txt
cmd 2> output_file.txt #redirect stderr to output_file.txt
cmd >& outpout_file.txt #redirect both stderr and stdout to output_file.txt
cmd1 | cmd2 #pipe cmd1 stdout to cmd2's stdin
cmd1 2>&1 | cmd2 #pipe cmd1 stdout and stderr to cmd2's stdin
cmd1 | tee result.txt #print cmd1's stdout to screen and also write to result.txt
cmd1 2>&1 | tee result.txt #print stdout,stderr to screen while writing to result.txt

(或者我们可以将其设为社区维基并在此处列举此类内容)

谢谢!

设置Jmp

最佳答案

关于shell - 展示 bash shell stdout/stderr 重定向行为的备忘单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2604141/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com