LoginSignup
0
1

More than 3 years have passed since last update.

[メモ]Linux標準入力、標準出力、標準エラー出力の操作例

Last updated at Posted at 2019-10-26

ファイル記述子

0・・標準入力
1・・標準出力
2・・標準エラー出力

標準出力、標準エラー出力のリダイレクト

・結果をfile1に出力
$ ls > file1

・結果をfile1に出力
$ ls 1> file1

・結果をfile1に出力(追記)
$ ls /bin >> file1

・エラーのみfile2に出力
$ ls aaa.txt bbb.txt 2> file2

・標準出力、標準エラー共にbothに出力
$ ls aaa.txt bbb.txt &> both

標準入力のリダイレクト

・file1の内容を標準入力経由で読み込めるようにしてコマンド1実行
$ コマンド1 < file1

・file1の内容を標準入力経由で読み込めるようにしてコマンド1を実行し、出力結果をコマンド2が標準入力から読み込めるようにする
$ コマンド1 < file1 | コマンド2
0
1
2

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
0
1