The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 09-02-2008
yogi_raj_143 yogi_raj_143 is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 16
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