Pages

Saturday, August 24, 2013

Shell script to assign each column value as a variable

Consider a txt file with two columns and many rows.

You may want to write a script which will take each column values in each row as variables

Then you can use the following script.



#!/bin/bash
cat text.txt | while read line;
do
var1=$(echo $line| awk '{print $1}')
var2=$(echo $line| awk '{print $2}')
done

No comments:

Post a Comment