Linux、CentOS - 2 つのファイルを比較するには、コマンドを使用します
comm --check-order -1 --output-delimiter=----- <sort(file1.txt) <sort (file3.txt) > result.txt ;
シェルで動作しますが、bash ファイルを作成しようとすると、
syntax error near unexpected token `('
スクリプトは最も単純です
#!/bin/bash
cd /var/www/html/compare/ ;
comm --check-order -1 --output-delimiter=----- <sort(file1.txt) <sort (file3.txt) > result.txt ;
exit ;
sh
私はすでに次のような丸括弧をエスケープしてバリエーションを試しました
sort\(file1.txt\)
また
sort'(file1.txt)'
しかし、この場合シェルは言う
sort(file1.txt)...: No such file or directory
のような絶対パスで試しました
<sort\(var/www/html/compare/file1.txt\)
同じ結果「そのようなファイルはありません」
そして、私はすでに次のようなバリエーションでスクリプトを実行しようとしました
sh /a/compare.sh
bash /a/compare.sh
chmod +x /a/compare.sh; ./a/compare.sh
それでも同じ問題。
したがって、OR「そのようなファイルはありません...」とブラケットのエスケープがあります-OR「予期しないトークン」他の場合。
試してみるアイデアを事前に感謝します。構文の正しい「組み合わせ」である必要がありますか?