I want to read a file with the data ordered in column.
In the script that I'm writing I use the read
command.
The input file is made by lines like the following:
XX:XX:XX:XX:XX PQRTS
YY:YY:YY:YY:YY ABCDE
ZZ:ZZ:ZZ:ZZ:ZZ FGHIJ
What I'm using to read it is something like this
while read a b; do
echo $a
echo $b
done < filename.txt
Till now it reads line by line and assigns XX:XX:XX:XX:XX
to a
and PQRTS
to b
in first iteration of the while
cycle, after YY:YY:YY:YY:YY
to a
and ABCDE
to b
in the second iteration, and so on.
Now my questions are:
- How can I use
a
andb
as global variables? - I want to assign
XX:XX:XX:XX:XX
,YY:YY:YY:YY:YY
so that I can use them in different functions.
$a
to something else in the loop.