在制作了一个创建目录的 bash 文件,然后将文件从一个目录传输到每个创建的目录之后,我很好奇如何在批处理文件中执行此操作。
这是 bash 代码:
#!/bin/bash
# For each item in file named in $1, make a directory with this name.
# and copy all files named in file $2 from templates folder to new directory
for user in `cat $1`
do
if [ -d $user ]
then
echo Directory $user already exists
rm -r $user
echo $user has been deleted
fi
mkdir $user
echo Directory $user created
for file in `cat $2`
do
cp /home/student/Desktop/OS/templates/$file $user
chmod 700 $user/$file
done
echo Directory for $user set up
done
任何投入将不胜感激