How To Redirect stderr To stdout ( redirect stderr to a File )

    技术2022-05-19  31

    3 default standard files (standard streams) open:[a] stdin - Use to get input (keyboard) i.e. data going into a program.

    [b] stdout - Use to write information (screen)

    [c] stderr - Use to write error message (screen)

    Understanding I/O streams numbers

    The Unix / Linux standard I/O streams with numbers:

    HandleNameDescription0stdinStandard input1stdoutStandard output2stderrStandard error

    Redirecting the standard error stream to a file

    The following will redirect program error message to a file called error.log:$ program-name 2> error.log$ command1 2> error.log

    Redirecting the standard error (stderr) and stdout to file

    Use the following syntax:$ command-name &>fileOR$ command > file-name 2>&1Another useful example:# find /usr/home -name .profile 2>&1 | more

    Redirect stderr to stdout

    Use the command as follows:$ command-name 2>&1


    最新回复(0)