2

Due to my lack of Bash knowledge I've tried for a few hours now to get something like this to work:

find Directories -mindepth 4 -type d -print0 | parallel -0 -j0 ./MyScript -d {Found Directory} {1} ::: a b c d

Where a,b,c and d are different arguments that my script needs to execute commands (in my case being -rb, -s, -is 20 44, -ib 13 25 .... and so on).

I need to execute the script once per argument for each found subdirectory while keeping the subdirectory information intact. The -d tells my script the target directory to execute itself in which works fine if {1} ::: a b c d is not there, if it is there then it just runs 4 times with a, b, c and d as arguments.

What I have is a large hierarchy of directories, which at depth 4 contains files that the script should execute different commands on based on what the argument {1} is.

Since this is a very resource and time consuming script I thought it would be nice to automate it with something like this, but I've clearly misunderstood something completely, anyone who can point me in the right direction ?

1 Answer 1

1
find Directories -mindepth 4 -type d -print0 | parallel -0 -j0 ./MyScript -d {2} {1} ::: a b c d :::: -
1
  • Ahh thank you so very much, that works! I ended up trying to put parallels inside parallels which were very slow. One thing though using '-is 20 44' is returning the argument as '-is\ 20\ 44' my futile googling has not nested me a solution to this, my script says they are invalid arguments.
    – Fidelis
    Commented Aug 16, 2015 at 18:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .