Linux 101 : Bash scripting - File redirections overview -



Below are a number of ways or examples we could use to redirect output or input in Bash.


The above expression sends the "command" output to file descriptor "a".


The above command sends the command's output that normally goes to the file with the descriptor "b" to the file with the "a" descriptor instead.


The above command closes the standard output. 
We could use it if we want for example to assign another output destination to a program.


The above command takes the arguments for "command" from the file with the descriptor "a".


For the above command, the arguments that would normally come from the file with the descriptor "b" will come from the file with the descriptor "a" instead.


The above command closes standard input.
We could use it if we want for example to assign another input source to a program.


The above command turns the file with the descriptor "a" into a standard input by duplicating it, and then closing the original standard input.


The above command turns the file with the descriptor "a" into a standard output by duplicating it, and then closing the original standard output.


The above command sends the output of the standard error to the file named "file".

Remark:

The standard output is unchanged.


The above command redirects the standard output and the standard error to the file named "file".


The above command redirects the standard output and the standard error to the file named "file".


The above command appends both the standard output and the standard error output to a file named "file".


The above command redirects the standard output to a file named "file_1" and standard error to a file named "file_2".


Comments

Leave as a comment:

Archive