Concatenating the two lines in a file

hi
My requirement is i have a file with some records like this

file name ::xyz

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

i want to change my file
a=1
b=100,200,300,400
c=700,800
d=900

if record starts with " , " that line should fallows the previous line.please give script or command to get my required output file

thanks

there is always a better solution,

#! /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

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

Another way:

while read LINE
do
echo ${LINE}|grep -qE "^,+"
if [ $? -eq 0 ] 
then
   echo "${LINE}\c"
else
   echo "\n${LINE}\c"
fi
done<input_file
echo
sed -e 'H;$!d;x;s/\n,/,/g' file > newfile

Another solution :

for i in `cat tt`
do
if [ `echo $i | cut -c1-1 ` = "," ]
then
prevline="$prevline$i"
else
echo $prevline
prevline=$i
fi
done
echo $prevline

While we're at it, another way:

#! /bin/bash

while read line; do
 [[ $line == ,* ]] && {
  printf "%s" "$line"
 } || {
  printf "\n%s" "$line"
}
done; printf "\n"

Accepts redirects and input from pipe, as does most of the others. I have to say, I like the sed example above. Pretty nifty...

Hi All,

How to combine the two lines of records in a single line using unix shell scripts.

here the file format:
first line
ABC0001 F0000000000677249 677
second line.
ABC00029980000 00000 USA0001099

I would like the output as following
ABC0001 F0000000000677249 677ABC00029980000 00000 USA0001099

need to merge the above two line into a single records.

Please help.

Thanks
ca_sr2274