次のスニペットを使用して、find によって指定されたファイルのリストにある AWK コマンドの上位 10 行を出力したいと考えています。
$ find . -name "*.txt" -print -exec awk '$9 != ""' \| head -n10 {} \;
処理中のファイル名を出力したいことにも注意してください。
しかし、なぜそのようなエラーが発生するのですか:
awk: cmd. line:2: fatal: cannot open file `|' for reading (No such file or directory)
./myfile.txt
それを行う正しい方法は何ですか?
パイプの前にバックスラッシュなしで試しました。それでもエラーが発生しました:
find: missing argument to `-exec'
head: cannot open `{}' for reading: No such file or directory
head: cannot open `;' for reading: No such file or directory