Creating thousands of files from shell

cd /var/www/vhosts && for d in */; do
   user=${d%%.*}
   echo "$user blah blah" > "${d}/conf/x.txt"
done

... should get you pretty much what you want.


Dennis and Mike make sure you're quoting ${dir}. If there are any directories with spaces this could result in some issues.

echo "$user and some static text..." > "${dir}/conf/x.txt"

For portability's sake I would use "${d%%.*}" for finding the user's name.


Here's another way to do it:

cd /var/www/vhosts &&
find -maxdepth 1 -mindepth 1 -type d -print0 |
while read -d '' -r dir
do
    user=$(basename "$dir" .company.com)
    echo "$user and some static text..." > "${dir}/conf/x.txt"
done