Reputation: 30697
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
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