[SOLVED] Subset a variable
by Drosera_capensis from LinuxQuestions.org on (#57CBA)
Hello everyone,
I wish to subset the columns of a variable, to use it in a while loop, and have not found the way to do it.
For a file set up as follow:
Code:a 1 2 3
b 4 5 6
c 7 8 9And the loop is the following:
Code:while read i < file
do
echo $i
doneAnd I wish to output only the first column:
Code:a
b
cIs it possible to subset the columns of $i using this specific variable?


I wish to subset the columns of a variable, to use it in a while loop, and have not found the way to do it.
For a file set up as follow:
Code:a 1 2 3
b 4 5 6
c 7 8 9And the loop is the following:
Code:while read i < file
do
echo $i
doneAnd I wish to output only the first column:
Code:a
b
cIs it possible to subset the columns of $i using this specific variable?