Is it necessary to use '1>' while redirecting standard output stream in Linux terminal? Here is the image..
This command is also working without using 1 while redirecting stdout in Linux....So My question is what is the difference between ' Using and not using 1 while redirecting Standard Output in Linux terminal'?
I tried with and without using 1 while redirecting Standard output stream in Linux...I got what i want all the time....But I need to know the difference between using and not using 1 while redirecting Standard output stream in Linux terminal.
CodePudding user response:
It is not necessary; the number is optional because it defaults to 1
when you omit it.
The general syntax is n>
where n is the number of an open file descriptor. You can open new file descriptors e.g. with exec
(so exec 3>&1
duplicates file descriptor 1 to file descriptor 3) or you can inherit open file descriptors from a parent process.
By default, the shell gives you standard input on file descriptor 0, standard output on 1, and standard error on 2, all connected to your terminal.