gpt4 book ai didi

linux - shell脚本背景

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:32:11 24 4
gpt4 key购买 nike

我有这样的脚本:fullscript.sh

if [ ! -f /opt/laks/linux-2.6.33.2.tar.bz2 ]

then

wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.33.2.tar.bz2

tar -xjf linux-2.6.33.2.tar.bz2

fi

for i in $(seq 1 500);

do

touch /tmp/$i.txt

done

我正在下载 tar 文件,然后将其解压缩,for 循环会创建 500 个新文件。

我想在后台运行“for循环”部分

我想在单个脚本 (fullscript.sh) 中执行此操作 - 所以我不能将 for 循环放在另一个脚本中并将其称为 ./forloop.sh &

最佳答案

通常你只需要运行一个子 shell 和后台:

( for i in $seq 1 500
do
touch /tmp/$i.txt
done
) &

关于linux - shell脚本背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2675632/

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