Files
spark-wine/spark-dwine-helper/s-wine-helper/deepinwine/tools/spark_updater
2023-04-13 16:48:07 +08:00

50 lines
948 B
Bash
Executable File

#!/bin/bash
# 检查是否提供了-c和-s选项
if [[ ! "$*" =~ "-c" ]] || [[ ! "$*" =~ "-s" ]]; then
echo "用法: updater -c <目标目录> -s <源目录> [-v]"
exit 1
fi
# 解析命令行参数
while getopts ":c:s:v" opt; do
case $opt in
c)
destination_dir=$OPTARG
;;
s)
source_dir=$OPTARG
;;
v)
verbose=true
;;
\?)
echo "无效选项: -$OPTARG" >&2
exit 1
;;
:)
echo "选项 -$OPTARG 需要一个参数." >&2
exit 1
;;
esac
done
# 从源目录复制文件到目标目录
if [ "$verbose" = true ]; then
echo "正在从 $source_dir 复制文件到 $destination_dir"
fi
# 使用mv命令覆盖同名文件
for file in "$source_dir"/*; do
if [ -f "$file" ]; then
mv -f "$file" "$destination_dir"
if [ "$verbose" = true ]; then
echo "已复制 $file$destination_dir"
fi
fi
done
echo "文件复制完成!"
exit 0