リダイレクトされたコマンド自体を出力ファイルリダイレクトにどのように含めることができますか?例えば
echo "hello!">output.txt
私が望む出力ファイルの内容は次のとおりです。
echo "hello!">output.txt
hello!
ベストアンサー1
これには2つのうちの1つが必要な場合があります。
使用
tee
echo
端末とファイルに転送された結果を取得します。$ echo 'hello!' | tee output hello! $ cat output hello!
script
完全な端末セッションをキャプチャするには:$ script Script started, output file is typescript $ echo 'hello!' >output $ cat output hello! $ exit Script done, output file is typescript
$ cat typescript Script started on Sat Nov 10 15:15:06 2018 $ echo 'hello!' >output $ cat output hello! $ exit Script done on Sat Nov 10 15:15:37 2018
これがあなたが要求したものではない場合は、質問を明確にしてください。