#!/bin/bash # ./run-each-row-and-column.sh # Israel Torres # 20120317 # Input a tab delimited file with two columns # Use three examples ending with the built-in # # create the tab delimted multiline text file echo -e "col1\tcol2\ndata1\tdata2" > data.txt # SAVEIFS=$IFS; IFS=$(echo -en "\n\b"); for x in $(cat data.txt) do # using cut #col1=$(echo $x | cut -f 1) #col2=$(echo $x | cut -f 2) #echo -e "[column 1]:$col1\t[column 2]:$col2" # # using awk #col1=$(echo $x | awk '{print $1}') #col2=$(echo $x | awk '{print $2}') #echo -e "[column 1]:$col1\t[column 2]:$col2" # # using builtin btab=$(echo -ne "\t") # create tab col1=$(echo ${x/$btab*/}) col2=$(echo ${x/*$btab/}) echo -e "[column 1]:$col1\t[column 2]:$col2" # done IFS=$SAVEIFS #EOF