ディレクトリからファイルを繰り返し抽出し、パラメータのあるファイルからexeを実行します。

ディレクトリからファイルを繰り返し抽出し、パラメータのあるファイルからexeを実行します。

さて、私がしたいことは次のとおりです。次のファイルがたくさんあります。

newnslog.0.tar.gz
newnslog.1.tar.gz
newnslog.2.tar.gz 
newnslog.3.tar.gz
newnslog.4.tar.gz
.
.
.

各ファイルを抽出したら、そのディレクトリ内のすべてのファイルを繰り返し、ファイルのデータに対してexeを実行したいと思います。

#extract:
tar -xzf newnslog.58.tar.gz
#cd:
cd newnslog.59 < yes the filename in the archive may be 1 more or less or the same as it is a continuation
#ls:
newnslog.ppe.0  newnslog.ppe.1  newnslog.ppe.2
#execute nsc2e with parameters against each file:
# ../nsc2e -c /netscaler/nsconmsg -K newnslog.ppe.0 -f ../nsc2e.conf

for - doループを試していますが、何か間違っているようです。

root@VPX-13# for f in *; do '../nsc2e -c /netscaler/nsconmsg -K "$f" -f ../ns2ce.conf'; done
-bash: ../nsc2e -c /netscaler/nsconmsg -K "$f" -f ../ns2ce.conf: No such file or directory
-bash: ../nsc2e -c /netscaler/nsconmsg -K "$f" -f ../ns2ce.conf: No such file or directory
-bash: ../nsc2e -c /netscaler/nsconmsg -K "$f" -f ../ns2ce.conf: No such file or directory

また、抽出を含むすべての作業を実行する簡単な方法が必要であることも知っています。たとえば、次のようになります。

find newnslog* -prune -type d | while IFS= read -r d; do 
    cd "$d"
    for f in *; do '../nsc2e -c /netscaler/nsconmsg -K "$f" -f ../ns2ce.conf'; done
done

ベストアンサー1

次のようにコマンドの周りの引用符を削除します。イルカチョ次のコメント:

for f in *; do ../nsc2e -c /netscaler/nsconmsg -K "$f" -f ../ns2ce.conf; done

...この問題を解決しました。

おすすめ記事