This won’t work as desired if we try to redirect both streams into the same file. What happens here is that both streams are redirected individually, and whichever comes second wins, rather than combining both into the same file.
If we want to redirect both into the same file, then we can use &> as we saw above, or else we can use stream combination operators. If we wish to use the stream combination operators, then we must do this after we have redirected into the file, or else only the standard output gets redirected:
$ ls -1 > log 2>&1
The final action that we can perform is to direct the output of one application into another one. This is commonly referred to as piping, and uses the | operator instead:
$ ls | wc
11 11 138
This directly connects the standard output of our first application into the standard input of the second one and then lets the data directly flow between them.
Do'stlaringiz bilan baham: |