gpt4 book ai didi

linux - shell 脚本 : Copy directory passed as variable to another directory also as variable passed by user

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:24:14 25 4
gpt4 key购买 nike

shell 脚本:我如何将用户作为变量传递的目录复制到另一个目录也作为变量?

我的意思是,用户键入源目录和目标。因此,目录中的文件被复制到另一个目录。

最佳答案

if cp -R "$source" "$destination"
then echo "Copy successful :)"
else echo "Copy failed :("
fi

cp-R 选项指定它应该递归地复制目录。 $source 应包含原始目录,$destination 应包含您要将其复制到的位置。

关于linux - shell 脚本 : Copy directory passed as variable to another directory also as variable passed by user,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15801599/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com