How to read variables from file, with multiple variables per line?

I think all you’re looking for is to read multiple variables per line: the read command can assign words to variables by itself.

while read -r first second third; do
    do_stuff_with "$first"
    do_stuff_with "$second"
    do_stuff_with "$third"
done < ./test.txt

Leave a Comment