gpt4 book ai didi

Unix - 如何在一个目录中获取多个 shell 脚本?

转载 作者:行者123 更新时间:2023-12-01 06:30:36 25 4
gpt4 key购买 nike

当我想在 Unix 中执行一些 shell 脚本时(假设我在脚本所在的目录中),我只需键入:

./someShellScript.sh

当我想 “来源”它(例如,在当前的 shell 中运行它,而不是在新的 shell 中运行),我只用 输入相同的命令“。” (或与“源”命令等效)在它之前:
. ./someShellScript.sh

现在是棘手的部分。当我想执行 “多个” shell 脚本(假设所有带有 .sh 后缀的文件)在当前目录中,我输入:
find . -type f -name *.sh -exec {} \;

但是 “我应该使用什么命令来“源”一个目录中的多个 shell 脚本” ?
到目前为止我试过这个,但它没有用:
find . -type f -name *.sh -exec . {} \;

它只抛出了这个错误:
find: `.': Permission denied

谢谢。

最佳答案

for file in *.sh
do . $file
done

关于Unix - 如何在一个目录中获取多个 shell 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1964671/

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