column - extract information from a file with loop - Ask Ubuntu


i need :) have file this:

aa bc fg  rf tt gh  dd ff hh 

(a few number of rows , 3 columns) , want put letters of each column in variable step step in order give them input in script. obtain:

for 1° loop:

var1 = aa var2 = bc var3 = fg 

for 2° loop:

var1 = rf var2 = tt var3 = gh 

for 3° loop:

var1 = dd var2 = ff var3 = hh 

if file has 3 whitespace-separated items on each line (no blank lines example) should able use simple while ... read loop:

while read -r var1 var2 var3;   ./otherscript "$var1" "$var2" "$var3" done < "file" 

if there blank lines, should read complete lines , parse non-empty ones e.g.

while ifs= read -r line;   if [[ -n "$line" ]];      read -r var1 var2 var3 <<< "$line"     ./otherscript "$var1" "$var2" "$var3"   fi done < "file" 

Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User