[英]Gnu/Linux (Bash) Bulk Command for Multiple Files
我正在尋找一種解決方案來同時運行多個文件的命令。
僅 1 個文件的示例:
dot -Tpng dummy.dot.modulename -o dummy.dot.modulename.png
現在以所有“ .dot ”為例(偽命令)
dot -Tpng $(find . -name "*.dot*") -o $(find . -name "*.dot*").png
遍歷 *.dot 文件通配模式
#!/usr/bin/env bash
for dotfile in *.dot
do
# Create the png file name by removing the trailing .dot
# and replacing it with .png
pngfile="${dotfile%.dot}.png"
dot -Tpng "$dotfile" -o "$pngfile"
done
而不是遍歷文件名通配擴展。 你可以讓find
執行這樣的命令/腳本:
find . -name '*.dot' \
-execdir sh 'for f; do dot -Tpng "$f" -o "${f%.dot}.png" ;done' {} \;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.