急!!编写一个Shell程序,它将第2个参数及其后的参数指定的文件复制到第1个参数指定的目录中。

2025-02-23 08:08:37
推荐回答(1个)
回答1:

if [ ! -d $1 ]
then
echo "$1 is not a dir"
exit 1
fi
dir=$1
shift
until [ $# -eq 0 ]
do
if [ -f $1 ]
then
echo "copy file $1 to $dir"
cp $1 $dir
else
echo "$1 is not a file,skip"
fi
shift
done