1. Use mkdir -p small/big to create small and its subdirectory big in one swell foop.
2. Copy some big images into small/big.
3. cd into small/big. You can iterate over the files like this:
for f in *.jpg ; do echo File $f: ; ls -l $f ; echo and thats all for file $f. ; done
You can also format it more nicely, and bash will let you know when you're inside the loop by giving a > prompt instead of the normal one:
for f in *.jpg
do
echo File $f
ls -l $f
etc...
done
4. You can use convert, part of the ImageMagick package, to convert an image from one type to another and to scale it (and to do many, many other things like cropping and overlaying text):
convert foo.jpg -scale '90%' smaller-foo.png
Challenge: use a for loop to convert each of the images in small/big into an image with the same name in small/.
Extra credit: Use seq to create a for loop that prints out the even numbers from 4 to 20, using sleep to pause 1/4 second between each number. Hint: you'll need to use backticks: ` around the call to seq. Explain in detail what the backticks do for double extra credit.
No comments:
Post a Comment