Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
teeUnix環境では、次のような一連のコマンドで使用したいと思います。
tee
$ echo 1; echo 2 | tee file 1 2 $ cat file 2
file最終的なコマンドからの出力しか得られないのはなぜですか?
file
この説明のために、それらを分解してコマンドを個別に実行することはできないと仮定しましょう。
セミコロンはシェルへの新しいステートメントを示すため、2番目のコマンドの出力のみが含まれます。
それらを括弧に入れるだけです:
(echo 1; echo 2) | tee file
試す:
( echo 1; echo 2 ) | tee file
括弧がないと、次のように解析されます。
echo 1 ; ( echo 2 | tee file )