Hello again unix.com.
How can I split a directory in 100 other ones. I have the directory "example.com" and I want to make 100 like it with names 1.example.com, 2.example.com, 3.example.com ... to 100.example.com.
Thanks.
Hello again unix.com.
How can I split a directory in 100 other ones. I have the directory "example.com" and I want to make 100 like it with names 1.example.com, 2.example.com, 3.example.com ... to 100.example.com.
Thanks.
i=1
while [ $i -le 100 ]
do
mkdir $i.example.com
i=`expr $i + 1`
echo " created $i.example.com directory"
done
Use the above script which creates you 100 directories. Run the script, where you want to make these directories.
Yes it creates the directories but the files in the example.com arent copied. I want the files to copy in those created directories also. Thanks.
In that case,
i=1
while [ $i -le 100 ]
do
mkdir $i.example.com
cp -pr example $i.example.com # recursively copies all the files and contents
i=`expr $i + 1`
echo " created $i.example.com directory"
done
Hope this helps
---------- Post updated at 09:54 PM ---------- Previous update was at 09:52 PM ----------
typo..
try this..
i=1
while [ $i -le 100 ]
do
mkdir $i.example.com
cp -pr example.com $i.example.com # recursively copies all the files and contents
i=`expr $i + 1`
echo " created $i.example.com directory"
done
Working but seems to make a additional directory example.com in the new created folders.
[root@mail www]# ls 57.example.com
example.com
LE: Nevermind, added /* and works fine. Thanks a million.
ksh93/zsh/bash:
mkdir {1..100}.example.com
sh:
seq 1 100 | xargs -I{} mkdir {}.example.com
For copy:
cp -r example.com {1..100}.example.com
The same with xargs.
no need for mkdir command
$ i=1;while [ $i -le 100 ]; do cp -prf example.com $i.example.com; i=$((i+1));done