loops in scripts
I am trying to batch process some files. So far I have used only single files, using
for i in ax bx cx dx nx etc... do command1 (e.g. /../test$i) command2 (e.g. /../test$i) done I have files that need to be "coupled". e.g. ax with dx, bx with cx, nx with nnx, .... all this is in a fairly random order and I have a table/matrix with the filenames coupled. They have to be processed together before going to the next one, and I can't figure out how to do it. e.g. commands will look like command1 ../../test/ax/dx command2 ../../test/ax/dx where the loop then should jump to command1 ../../test/bx/cx command2 ../../test/bx/cx etc. THANKS!!!! |
I don't fully understand what you are trying to do, some more explanation would be very helpful.
|
Basically I need to use 2 linked variables in one command line, repeat a few commands with this set of variables. Then next 2 variables need to go through the same set of commands are unrelated to the first 2, etc.
With "for i in..." I have been able to do this type of a loop with a single variable, but combining multiple sets of 2 linked variables within one loop I have not been able to figure out. Hope that clarifies it better, not sure how better to put it. Thanks |
Like this?
Code:
#!/bin/bash Code:
command1 ../../test/ax/dx Just remove the echo from the lines to actually run the commands, rather than just printing out what it would run. |
Another take would be to use your file with the pairings in it. Assuming this looks like:
Code:
$ cat pairing_file Code:
while read -r first second |
Thank you so much, that worked perfectly.
|
Please remember to mark as SOLVED once you have a solution.
|
It was just amazing information sharing and it's helpful for everyone.
|
All times are GMT -5. The time now is 09:44 AM. |