whileループ内の正規表現または同様のbashフィルタファイル名

whileループ内の正規表現または同様のbashフィルタファイル名

現在ディレクトリにあるすべてのファイルの幅と高さを取得する次のbashスクリプトがあります。

ls | cat -n | while read n f; do 
  width=$(identify -format "%w" "$f")
  height=$(identify -format "%h" "$f")
  echo "$width , $height"
done

ファイル名で終わるファイルの高さ/幅を取得するには-example99.jpg

ベストアンサー1

for filename in *-example99.jpg
do
  width=$(identify -format "%w" "$filename")
  height=$(identify -format "%h" "$filename")
done

おすすめ記事