linux - 如何编写 shell 脚本来复制脚本所在目录中的文件

标签 linux shell

我正在运行一个 shell 脚本,例如 xyz.sh。此 shell 脚本需要将该脚本所在的同一目录中存在的所有文件复制到另一个文件夹。有什么办法可以做到吗?

最佳答案

TARGETDIR='z';for file in *;do test "$file" != "$TARGETDIR" && cp -r "$file" "$TARGETDIR/";done

关于linux - 如何编写 shell 脚本来复制脚本所在目录中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15573071/

相关文章:

linux - 启动-停止-重启 shell 脚本的功能

java - 在 Docker 中运行 Python 和 Java

linux - mcedit 和 mcview - 子 shell 在 Ubuntu Linux 上不起作用,在 mc 上 - 运行良好

bash - shell脚本,在并行进程中运行

ruby - 如何让 Yardoc 输出到 STDOUT?

php - 来自 PHP 的带有 SFTP 的 shell 脚本

python - 尽管我在 python ctypes 中设置了信号处理程序,但它不会被调用

java - 打印 ASM 代码以生成给定的类用法 : ASMifier [-debug] <fully qualified class name or class file name>

linux - 在基于 Linux 的操作系统中有没有办法确定复制到 X 剪贴板的文本源?

linux - 这个Centos 8系统怎么安装postgis?获取 "Error: Problem: cannot install the best candidate for the job"