use >
> should be preceded with a number, such as 2> , but default is 1 if no number
ex:
ls > output
equals
ls 1> output
Sending Both Output and Error Messages to Different Files
test 1> messages.out 2> message.err
or
test > messages.out 2> message.err
2 means STDERR
add & after >:
means the output is redirected to a file descriptor
ex:
ls >& 2
write STDOUT & STDERR to the same place:
ex:
ls >& outfile
or
ls > outfile 2>&1
沒有留言:
張貼留言