Hello gurus,
I produce a number of .loc files in parallel depending on number of .csv in the folder
for file in *csv
do
./process.sh $file > $file.loc &
done
then I want to compile all the output from the previous step into a single masterlocfile and then perform the rest of the steps
cat *.loc > masterlocfile
How can I make sure all the .loc files have been completely created (the for loop has ended) before moving onto the next steps including compilation?
I got some answers from google that involves a process id but I will have several different process id from the for loop. Please help.
drl
October 5, 2017, 12:25pm
2
Hi.
$ type wait help ; help wait
wait is a shell builtin
help is a shell builtin
wait: wait [-n] [id ...]
Wait for job completion and return exit status.
Waits for each process identified by an ID, which may be a process ID or a
job specification, and reports its termination status. If ID is not
given, waits for all currently active child processes, and the return
status is zero. If ID is a a job specification, waits for all processes
in that job's pipeline.
If the -n option is supplied, waits for the next job to terminate and
returns its exit status.
Exit Status:
Returns the status of the last ID; fails if ID is invalid or an invalid
option is given.
On a systerm like:
OS, ker|rel, machine: Linux, 3.16.0-4-amd64, x86_64
Distribution : Debian 8.9 (jessie)
bash GNU bash 4.3.30
Best wishes ... cheers, drl
2 Likes
Beware that if you have many files that you might hit processing limits (such as number of process per user, total process on the system etc.) so might need to break down your list into smaller chunks.
Is this likely to be the case are we looking at 100 or less files?
Robin