Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work. Try for free Learn more
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work. Try for free Learn more
find -exec の中でパイプを使って複数コマンドを実行する方法について説明します。 パイプを使った実行例 ここでは、カレントディレクトリ以下にあるファイルの中身を全て小文字にするコマンドを書くことを例に説明していきます。 一つのファイルだけであれば、次のコマンドでできます。 cat input.txt | tr 'A-Z' 'a-z' > input.txt.lower これをそのまま、find -exec で実行しようとしても上手く動きません。 # 動かない例 find . -type f -name '*.txt' -exec cat {} | tr 'A-Z' 'a-z' > {}.lower \; 原因は -exec の後ろには1つのコマンドしか取れないからです。 find でパイプを使う方法 代わりに、sh -c "実行したいコマンド" と書くことで複数のコマンドを一つのコ
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く