DevLion
DevLion

Reputation: 3

How to append text to the output file redirected by perl command

The command

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

is redirecting output to the file. But it is overriding the file every time. How to append the text to the end of existing file?

Upvotes: 0

Views: 553

Answers (1)

user252592
user252592

Reputation: 141

To append, you can use >> instead of >.

In your case, the new command will be:

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

2>&1 is redirecting the stderr to stdout (the output of stderr will also be saved in output.txt), so you don't need >> there.

Upvotes: 1

Related Questions