Chan Chen Coding...

          導航

          統計

          文章分類

          文章檔案

          最新評論

          Redirect stderr To stdout

          Q. How do I redirect stderr to stdout? How do I redirect stderr to a file?

          A. Bash and other modern shell provides I/O redirection facility. There are 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:

          HandleNameDescription
          0stdinStandard input
          1stdoutStandard output
          2stderrStandard 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 &>file
          OR
          $ command > file-name 2>&1
          Another useful example:
          # find /usr/home -name .profile 2>&1 | more

          Redirect stderr to stdout

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



          -----------------------------------------------------
          Silence, the way to avoid many problems;
          Smile, the way to solve many problems;

          posted on 2012-05-18 07:40 Chan Chen 閱讀(384) 評論(0)  編輯  收藏 所屬分類: Linux

          主站蜘蛛池模板: 平邑县| 湄潭县| 阿拉善左旗| 江川县| 稷山县| 高淳县| 循化| 阳山县| 泰宁县| 溆浦县| 盐山县| 洞头县| 湘乡市| 秀山| 商都县| 鄂尔多斯市| 高州市| 闽侯县| 手游| 鸡泽县| 东乌珠穆沁旗| 肇源县| 乌拉特中旗| 平顶山市| 于都县| 崇明县| 习水县| 龙口市| 留坝县| 岱山县| 丽江市| 曲阳县| 阳山县| 左云县| 平武县| 威宁| 房山区| 吕梁市| 清丰县| 习水县| 康马县|