LoginSignup
2
2

More than 3 years have passed since last update.

Shell Linux コマンド の 実行結果 を ファイル に 出力する

Last updated at Posted at 2021-02-10

目的

  • Linuxでコマンドを実行したときのすべてのログをファイルに記載し、ターミナル上にも出力する方法を知る。

書き方の例

  • 下記にShellの処理を記載する。
$ 実行コマンド 2>&1 | tee 結果を記載するファイル名

より具体的な例

  • コマンドecho "Hello miriwo"の実行結果をテキストファイル「result.txt」に記載する。
  • 下記にShellの処理を記載する。
$ echo "Hello miriwo" 2>&1 | tee result.txt
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2