|
Some thing similar
+++++++
cat filename | paste -s -
+++++++
Or for more advance operations, I have awk script by some forum like this
+++++++
#! /bin/sh
## ------------------------------------------------------------
## -- Transpose a matrix:
## -- Assumes all lines have same number of fields
## --
## -- Usage:
## -- script <STDIN> ^D
## -- script <input file>
## -- cat <input file> | script
## ------------------------------------------------------------
exec awk '
BEGIN {
FS = ","
OFS = ","
}
NR == 1 {
n = NF
for (i = 1; i <= NF; i++)
row[i] = $i
next
}
{
if (NF > n)
n = NF
for (i = 1; i <= NF; i++)
row[i] = row[i] "," $i
}
END {
for (i = 1; i <= n; i++)
print row[i]
}' ${1+"$@"}
+++++++
This assumes "," as input file field seperator
|