このコマンドは何をしますか?

このコマンドは何をしますか?
cat telephone.txt | cat | cat | sed -e "s/t/T/" | tee cible | wc -l

ベストアンサー1

このようなコマンドがある場合は、各部分を試して、そのコマンドが何をしているのかを確認してください。

たとえば、次のそれぞれを実行して実行される操作を確認します。

cat telephone.txt
cat telephone.txt | cat
cat telephone.txt | cat | cat
cat telephone.txt | cat | cat | sed -e "s/t/T/"
cat telephone.txt | cat | cat | sed -e "s/t/T/" | tee cible
cat telephone.txt | cat | cat | sed -e "s/t/T/" | tee cible | wc -l

これを行うと、次のようになります。

cat telephone.txt <-- reads file
cat <-- reads stdin and prints to stdout (from comments)
cat <-- reads stdin and prints to stdout (from comments)
sed -e "s/t/T/" <-- replaces the first lower case t on each line with an upper case T
tee cible <-- reads stdin and prints to stdout and also writes it to a file called "cible"
wc -l <-- counts the lines of stdout from above

おすすめ記事