bux
bux

Reputation: 7769

Make a "for i in $(...) in bash" command on linux

I'm trying to execute a command line on each .jpg file in folder:

for i in ls *.jpg; do convert $i -resize 400x511 -gravity center -background white -extent 400x511 $i; done

But only the first .jpg is "done", what is wrong ?

Upvotes: 2

Views: 2292

Answers (1)

anubhava
anubhava

Reputation: 785761

First of all you don't need ls here and 2nd you need to quote it.

for i in *.jpg; do
    convert "$i" -resize 400x511 -gravity center -background white -extent 400x511 "$i"
done

Upvotes: 1

Related Questions