Morki
Morki

Reputation: 215

Pair wise input redirect - bash

I have a file called input.txt which has the following

0 
1
1 
2
2
3
3
4

What I would like to do is redirect two lines to a programing like so:

i = 0;

./program < input.txt[i & ++i]

in a loop until it is done with the file.

Anyone know how? Thanks

Upvotes: 0

Views: 54

Answers (1)

that other guy
that other guy

Reputation: 123500

while read line1 && read line2
do
    printf "%s\n" "$line1" "$line2" | ./program
done < input.txt

Upvotes: 1

Related Questions