How to create a series of directories using a standard format.
1 | printf "image%01d\n" $(seq 0 3) | xargs -I{} mkdir {} |
Let’s see the result :
1 2 | $ ls image* image0/ image1/ image2/ image3/ |
Delete all this folder is easy, just use this command:
1 | printf "image%01d\n" $(seq 0 3) | xargs -I{} rm {} -f -r |
How to create a series of text files using a standard format.
1 | printf "text%01d\n" $(seq 0 3) | xargs -I{} touch {}.txt |
Let’s see the result :
1 2 3 | $ ls text*.txt text0.txt text1.txt text2.txt text3.txt |
How to create a series of random GIF images named with the same numbers.
1 2 3 4 5 6 7 8 9 | #!/bin/bash # $RANDOM returns a different random integer at each invocation bettwen 0 - 32767 (signed 16-bit integer). args=("$@") for i in $( seq ${args[0]} ) do rand=$RANDOM; printf $rand $(seq 0 3) | xargs -I{} convert -background lightblue -kerning -6 -fill blue -font Trebuchet-MS-Regular -pointsize 36 -size 75x -swirl 60 caption:$rand $rand.gif done |
Let’s see the result :
1 2 | $ ls *.gif 14182.gif 20631.gif 21515.gif 21763.gif 29000.gif 6520.gif |
Thank you.