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

          主站蜘蛛池模板: 城口县| 松潘县| 诸暨市| 庆云县| 白银市| 长寿区| 南昌市| 乌兰浩特市| 河南省| 苏尼特右旗| 新巴尔虎左旗| 利川市| 威远县| 普安县| 永川市| 胶南市| 广安市| 高青县| 石楼县| 馆陶县| 内江市| 寿阳县| 泾川县| 鲁甸县| 东乌珠穆沁旗| 漾濞| 西安市| 湘西| 朝阳市| 丰顺县| 开原市| 德钦县| 冀州市| 辰溪县| 崇阳县| 余庆县| 藁城市| 无棣县| 上杭县| 泸定县| 深圳市|