I'm trying to write a Ruby script that goes into each sub-directory in a directory, and then executes several commands. I am using the System() command to execute some of them. Based on the documentation, I thought that System() should wait for a subprocess to end before proceeding further. However, it does not appear to do so. This is a simplified version of my script:
Dir.glob("**/") do |subdir|
Dir.chdir(subdir) do
system("gunzip *paired.fastq.gz")
end
end
I want it to run gunzip on one or all of the appropriate files in the first subdirectory, and once these gunzip processes are ended, then go to the next subdirectory and so on. But right now, it just creates gunzip processes for files in all of the subdirectories simultaneously. Am I misunderstanding the System() documentation? Is there any other command I should use instead ?
Thanks !!!