I have a shell script that takes three arguments, which need to come from a single line of a text file.

Example text file:

1   1   2300000
1   2300001 5300000
1   5300001 7100000
1   7100001 9200000
1   9200001 12600000

I want to run the script once for each line:

sbatch script 1 1   2300000
sbatch script 1 2300001 5300000

... And so on

I'm trying to write code to include these three arguments for every line of the text file. So far, I've tried a few things, including:

while read x y z in text
    ./script $x $y $z

I've found similar questions on here but they don't quite answer my problem. I'm about ready to just submit each line manually, so any help or suggestions on how to do this would be greatly appreciated!


1 Answer 1

while read x y z; do
    ./script "$x" "$y" "$z"

note FILENAME and not using in text

Check bash FAQ #1

You must log in to answer this question.

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