O.rka
O.rka

Reputation: 30697

How to iterate through elements of the first column of a text file using bash?

I'm trying to grab each element in the first column of a text file using bash.

How can I read each element in as a variable?

for ID_SAMPLE in cut -f1 manifest.tsv
do
echo $ID_SAMPLE
done


$ bash test.sh
cut
-f1
manifest.tsv

Upvotes: 1

Views: 4278

Answers (1)

MassPikeMike
MassPikeMike

Reputation: 682

for ID_SAMPLE in $(cut -f1 manifest.tsv)
do
 echo $ID_SAMPLE
done

or backticks:

for ID_SAMPLE in `cut -f1 manifest.tsv`; do echo $ID_SAMPLE; done

Upvotes: 3

Related Questions