The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 -->
  #2 (permalink)  
Old 06-26-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,953
there is always a better solution,

Code:
#! /usr/bin/ksh

awk '{ if( $0 ~ /^,/ ) { printf "%s 1\n",$0 } else { printf "%s 0\n",$0 } }' file | while read
line ind
do
  if [ $ind -eq 0 ]
  then
     echo $var
     var=""
  fi
  var=$var$line
done
echo $var

exit 0
your input file had
,500,600

i believe they should also be appended with the previous lines,

o/p of the above script
Code:

a=1
b=100,200,300,400,500,600
c=700,800
d=900