Bash 如何将文本追加到perl命令重定向的输出文件中

Bash 如何将文本追加到perl命令重定向的输出文件中,bash,shell,redirect,Bash,Shell,Redirect,命令 perl myperlscript.pl > output.txt 2>&1 正在将输出重定向到文件。但它每次都会覆盖该文件。如何将文本追加到现有文件的末尾?若要追加,可以使用>而不是 在您的情况下,新命令将是: perl myperlscript.pl >> output.txt 2>&1 2>&1将stderr重定向到stdout(stderr的输出也将保存在output.txt),因此您不需要>。也许perl myperlscript

命令

perl myperlscript.pl > output.txt 2>&1

正在将输出重定向到文件。但它每次都会覆盖该文件。如何将文本追加到现有文件的末尾?

若要追加,可以使用
>
而不是

在您的情况下,新命令将是:

perl myperlscript.pl >> output.txt 2>&1

2>&1
将stderr重定向到stdout(stderr的输出也将保存在
output.txt
),因此您不需要
>

也许
perl myperlscript.pl>>output.txt 2>&1
?这在bash手册页中有很好的说明。对于联机资源: