webminal.org
webminal.org

Reputation: 47196

shell script background

I have script like this : 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

I'm downloading tar file and then decompress it and for loop creates 500 new files.

I want to run "for loop" part as background

I want to do this in a single script (fullscript.sh) - So i can't put for loop in another script and call it as ./forloop.sh &

Upvotes: 1

Views: 485

Answers (1)

paxdiablo
paxdiablo

Reputation: 881103

Normally you would just run a sub-shell and background that:

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

Upvotes: 5

Related Questions