07th Dec 2008
Create 1000 files / directories with one command (*NIX)
I have to write it down, because I always forget it. But it’s so easy though… just have to remember the “seq” command.
Example:
for i in $(seq 1 1000); do touch File_$i; done
or, for creating folders:
for i in $(seq 1 1000); do mkdir Directory_$i; done
Obviously you can specify whatever sequence of numbers you want.
“seq” command is not available on MAC’s bash. And I believe also on some version of *BSD. You can use instead the “jot” command. It acts a bit different, but you’ll get the hang of it. The first argument specifies how many numbers to count and the second argument sets the start number. So to generate a sequence from 1 to 1000 you’d type:
jot 1000 1
and in our example, would be:
for i in $(jot 1000 1); do mkdir Directory_$i; done
==========================================
Here’s an interesting script created to adjust “jot” to behave exactly like “seq” plus the wonderful benefit of padding the numbers:
http://fredrik-rodland.blogspot.com/2008/10/seq-on-mac-os-x.html
Thanks, fredrik!
P.S.: You gurus out there… please don’t smile. This is for newbies like myself… 
I have to write it down, because I always forget it. But it’s so easy though… just have to remember the “seq” command.
Example:
for i in $(seq 1 1000); do touch File_$i; done
or, for creating folders:
for i in $(seq 1 1000); do mkdir Directory_$i; done
Obviously you can specify whatever sequence of numbers you want.
“seq” command is not available on MAC’s bash. And I believe also on some version of *BSD. You can use instead the “jot” command. It acts a bit different, but you’ll get the hang of it. The first argument specifies how many numbers to count and the second argument sets the start number. So to generate a sequence from 1 to 1000 you’d type:
jot 1000 1
and in our example, would be:
for i in $(jot 1000 1); do mkdir Directory_$i; done
==========================================
Here’s an interesting script created to adjust “jot” to behave exactly like “seq” plus the wonderful benefit of padding the numbers:
http://fredrik-rodland.blogspot.com/2008/10/seq-on-mac-os-x.html
Thanks, fredrik!
P.S.: You gurus out there… please don’t smile. This is for newbies like myself… ![]()
Posted by marian under
General Computers, MAC, Linux
No Comments »