how to append on file in IO redirection 1

how to append on file in IO redirection

cmd >>file.txt 2>&1

>>file.txt: Open file.txt in append mode and redirect stdout there.
2>&1: Redirect stderr to "where stdout is currently going". In this case, that is a file opened in append mode. In other words, the &1 reuses the file descriptor which stdout currently uses.

Here is what the above code is Doing:
1. Open file.txt in append mode and redirect stdout there.
2. Redirect stderr to “where stdout is currently going”. In this case, that is a file opened in append mode. In other words, the &1 reuses the file descriptor which stdout currently uses.

Similar Posts