in a bash script i do run this:
seq 1 $(<howmany.txt) | xargs -I% -n1 -P$(<parallel.txt) mycommand --infile file% --option A --outfile file%.new
it works.
the values in howmany.txt
and parallel.txt
comes from other scripts into these files.
in this example here is the value 48
in howmany.txt
and the value 4
in parallel.txt
.
howmany.txt
is ever in a range from not less than 4
and the maximum not over 99
.
parallel.txt
is ever in a range from not less than 4
and the maximum not over 16
.
how to add a new feature: --option N
?
in options.txt are the values: A, B and C :
in line 1 is the value: `A`
in line 2 is the value: `B`
in line 3 is the value: `C`
how can it randomize to do in 50% to use --option A
, 25% to use --option B
and the rest (25%) to use --option C
?
in some cases where it can not clear divide, there must be round up or down, that is no problem. is it possible to set it up in such a way that an option D could be added later?
the best way could be if it possible to options.txt
to write
50 A
25 B
rest C
or
40 A
20 B
15 C
rest D
edit:
with quotes "
, it does not work, dont know why ... but it works here for me only without quates around my constructs.
i try it with --option $(shuf -n1 options.txt)
in options.txt
in line 1 is A in line 2 is B and so on....
i try it with sort -R | tail -n1
instead of shuf -n1
, and xargs with -P1
too. nothing brings me "random options" with xargs. dont know what is wrong here, but if i test in a terminal sort -R | tail -n1
and or shuf -n1
with options.txt it brings me everytime random output, that works, but it does not work combined with xargs?
what do i wrong?!?