Passing Single Argument to Multiple Scripts
I have 12 scripts in a single folder. And i need to pass 'dry' as a parameter to each of this scripts. But i want to pass 'dry' parameter to first script then wait for it to complete its execution. Then i need to start the second script again using dry as parameter and so on.
The 12 files are named as follows- 01-xxx.sh 02-xxx.sh 03-xxx.sh . . . . . . 10-xxx.sh . 12-xxx.sh I wanna do like below- > sh 01-xxx.sh dry > wait for its execution to finish > sh 02-xxx.sh dry > wait for its execution to finish and so on for the remaining scripts Can anyone provide me the solution for the above problem? |
I don't see a problem to fix here really. You want to run them automatically one after another? You can easily just put them in a script, one after another. If you want to avoid just typing "dry" in 11 saves, just put "$1" as the parameter on each line and pass that as a parameter to the noddy script.
Code:
#!/bin/bash Code:
# sh myscript.sh dry |
how about
Code:
for i in ./{01..12}-xxx.sh; do $i dry; done |
How to control the execution of the scripts based on time and memory constraints?
How to find out the time and memory requirement of a script? |
Well that's nothing in the slightest bit related to what you originally asked, is it?
This is reading a lot like homework to me now, and we aren't here to prevent you having to learn. |
Hey that is the next step i need to implement in my code. It just that i wanna control the execution of those scripts so that segmentation issues do not arise as these are memory intensive scripts.
I am going slow so that i can grasp the logic and will put it together all at once. Hope its OK........ |
Quote:
can you modify the code if my scripts are named as below- 01-bwa.sh 02-resolvemerge.sh etc Keep in mind that the naming starts with 01 and ends to 12. i think your loop is just taking 1-bwa.sh and not 01-bwa.sh. Please modify the logic as per my needs. thanks in advance.... |
Surely a loop is just a nice little bonus? You have twelve lines, just type them out...??
|
the
Code:
./{01..12}-xxx.sh Code:
./{01..12}-*.sh |
Quote:
-bash-3.2$ for i in ./{01..12}-*.sh; do ./$i dry; done -bash: ././1-*.sh: No such file or directory -bash: ././2-*.sh: No such file or directory -bash: ././3-*.sh: No such file or directory -bash: ././4-*.sh: No such file or directory -bash: ././5-*.sh: No such file or directory -bash: ././6-*.sh: No such file or directory -bash: ././7-*.sh: No such file or directory -bash: ././8-*.sh: No such file or directory -bash: ././9-*.sh: No such file or directory Why its taking 1-*.sh and not 01-*.sh? |
That's because you are using bash-3.2, which does not support leading zeroes in brace expansion. It works correctly in bash-4.x, though.
This might work for you: Code:
for i in {1..12}; do $(printf "./%02i-*.sh*" $i) dry; done |
seriously... overkill anyone?
|
Quote:
|
Quote:
Code:
for i in $(seq -w 12); do ./$i-*.sh dry; done |
All times are GMT -5. The time now is 09:02 AM. |