these commands are equally valid, both commands add „content“ to the end of file – if file does not exists it will be created.

echo "content" >> file;

>>file echo "content";

echo $?; # returns the error level (1 = error, 0 = success) of the last run command/application/programm/script
0

Bash / ksh and other modern shell on Linux has three file descriptors:

stdin (0)
stdout (1)
stderr (2)

Syntax To redirect all error to file

The syntax is as follows to redirect errors (stderr) as follows:

command 2> error_messages_go_here.txt

command > normal_output_goes_here.txt 2> error_messages_go_here.txt

normal_output and error_messages

go into the same file

command > everything.txt 2>&1

output normal_output and error_messages to file and screen

#!/bin/bash
# My script to do blah ...
{
   command1
   command2
} 2>&1 | tee script.log

src: https://www.cyberciti.biz/faq/linux-redirect-error-output-to-file/

admin