Hi,
I have the following type of data that is separated by tabs:
-2 abandonar abandono abandonas abandona abandonamos abandon�is abandonan
-4 abandonado abandonada abandonados abandonadas
-2 abandona abandonos
-3 secuestrado secuestrada secuestrados secuestradas secuestrar�a secuestrar�as secuestrar�amos secuestrar�ais secuestrar�an
I need to keep the values in Column 1, but I need each string in the following columns to be moved to their own line. The desired result would be this:
-2 abandonar
-2 abandono
-2 abandonas
-2 abandona
-2 abandonamos
-2 abandon�is
-2 abandonan
-4 abandonado
-4 abandonada
-4 abandonados
-4 abandonadas
-2 abandona
-2 abandonos
-3 secuestrado
-3 secuestrada
-3 secuestrados
-3 secuestradas
-3 secuestrar�a
-3 secuestrar�as
-3 secuestrar�amos
-3 secuestrar�ais
-3 secuestrar�an
Is there a function in
awk
that would permit this type of action?
Simple writing out what I need to print on each line � la
$awk '{print $1, $2, etc}'
would be very cumbersome, especially because there are
n-columns
So far, I have tried out some
awk
solutions that help to solve problems regarding transposing the data, such as this:
awk '{ for (i=1;i<=NF;i++ ) printf $i " " }'
and
awk '{
for (f = 1; f <= NF; f++) { a[NR, f] = $f }
}
NF > nf { nf = NF }
END {
for (f = 1; f <= nf; f++) {
for (r = 1; r <= NR; r++) {
printf a[r, f] (r==NR ? RS : FS)
}
}
}' input
However, they do not exactly solve the problem because I want each column to also be attached to the original value of its row in Column 1.
Any ideas?