bash - Linux create columns from row -
i have text file values, , i'm trying create , fill column specific row in file. more precise, input following:
<name>relative 1</name> 0.624790,-0.000000,0 0.493925,0.591035,0 0.363039,1.182079,0 <name>relative 2</name> -24.621334,0.000000,0 -24.752199,0.591031,0 -24.883085,1.182072,0 <name>relative 3</name> -49.868542,0.000000,0 -49.999397,0.591014,0 -50.130271,1.182033,0
and expected output should be:
0.624790,-0.000000,0 <name>relative 1</name> 0.493925,0.591035,0 <name>relative 1</name> 0.363039,1.182079,0 <name>relative 1</name> -24.621334,0.000000,0 <name>relative 2</name> -24.752199,0.591031,0 <name>relative 2</name> -24.883085,1.182072,0 <name>relative 2</name> -49.868542,0.000000,0 <name>relative 3</name> -49.999397,0.591014,0 <name>relative 3</name> -50.130271,1.182033,0 <name>relative 3</name>
the solution in bash, awk or sed.
thanks in advance help.
using awk:
awk '/^</{s=$0;next}{print $0,s}' file.txt
when line begins <
, set variable s
contents of line , skip next line. on other lines, print contents of line, followed contents of s
.
bash awk sed row multiple-columns
No comments:
Post a Comment