I have infile with values for 2 variables
# cat infile
A 1
B 2
C
D
E
I want to read variable a & b, so that if $b has null value, it should repeat like 1..2, till all $a values are read.
so if I use a loop that does echo $a $b
# cat loop.sh
#!/usr/bin/env bash
cat infile | while
read a b
do
echo $a $b
done
result is somewhat same as infile.
But I want an if statement that should repeat $b, so that it should echo
A 1
B 2
C 1
D 2
E 1