gpt4 book ai didi

bash - 运行多个批处理文件但有异常(exception)

转载 作者:行者123 更新时间:2023-11-29 09:19:55 24 4
gpt4 key购买 nike

我有大约 100 个 files.sh 可以通过以下方式运行:

for files in The_job_*;do
sbatch $files;
done

但是在这 100 个文件中的一个中,我不想运行 5 个文件,所以我想这样说:

for files in The_job_*;do
sbatch $files except for "The_job_345", "The_job_567", "The_job_789";
done

谢谢你的帮助,如果你有想法?

最佳答案

您可以像这样使用扩展的 glob(查看 Pattern Matching section in the reference manual 的末尾):

shopt -s extglob

for file in The_job_!(345|567|789); do
# Don't forget the quotes:
sbatch "$file"
done

另一种可能是:

# If using bash 3, you'll need to turn extglob on (uncomment the following line)
# shopt -s extglob

for file in The_job_*; do
if [[ $file = The_job_@(345|567|789) ]]; then
continue
fi
sbatch "$file"
done

如果您有很多文件要跳过,那么在数组或关联数组中声明它们可能更容易...但是由于您只有 5 个文件,所以我给您的任何一种可能性都应该没问题。

关于bash - 运行多个批处理文件但有异常(exception),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54295021/

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