I have a script in tcl in which a variable gets a collection of data in every loop and appends in a file. Suppose in loop1 ,

$var = {xy} {ty} {po} {iu} {ii}

and in loop2

$var = {a} {b} {c} {d1} {d2} {e3}

Now in a file f.txt the variable in dumped. Like puts $file $var. And in file it comes like this: Line number 1: {xy} {ty} {po} {iu} {ii}

Line number 2: {a} {b} {c} {d1} {d2}

I want to print them finally in a file in tabular format. Like below:

xy  a

ty  b

po  c

iu  d1

ii  d2

1 Answers

0
Håkon Hægland On

Try this:

$ perl -anE 'push @{$vars[$_]}, ($F[$_] =~ s/^[{]|[}]$//gr) for 0.. $#F; END {say join "\t", @$_ for @vars}' f.txt
xy  a
ty  b
po  c
iu  d1
ii  d2