Appearance
Linux-Command
文件权限设置
sh
# 部分权限
chmod -R 755 /path/to/xxxx
# 全部权限
chmod -R 777 /path/to/xxxx
rsync 复制文件
- 动态复制指定的文件夹 or 文件
sh
#!/bin/sh
# 输入源目录
read -p "Enter your from path: " INPUT1
# 输入新目录
read -p "Enter your target path: " INPUT2
# 按输入目录执行命令
rsync -a --no-o --no-g --delete $INPUT1 $INPUT2
删除文件
- 循环删除指定的文件夹 or 文件
sh
#!/bin/sh
sourceDir=/mydata/www_nodejs/
targetDir=/usr/share/nginx/html/
arr=("assets" "guide" "linux" "nestjs" "hashmap.json" "index.html")
for i in "${arr[@]}"; do
echo "$targetDir/$i"
rm -rf "$targetDir/$i"
done