编写linux脚本用于复制目录下所有问题但是需要保留符号连接
#!/bin/bash
复制目录下的所有文件,保留符号连接
echo "请输入源目录路径:" read source_dir
echo "请输入目标目录路径:" read target_dir
验证目录是否存在
if [ ! -d "$source_dir" ]; then echo "源目录不存在!" exit 1 fi
if [ ! -d "$target_dir" ]; then echo "目标目录不存在!" exit 1 fi
复制目录下的所有文件,保留符号连接
cp -R -P "$source_dir"/* "$target_dir"
echo "复制完成!"
原文地址: https://www.cveoy.top/t/topic/fibZ 著作权归作者所有。请勿转载和采集!