Help with shell script in formatting the records.

I have a text file in the following format. can any one please help me in printing the output in userfriendly format mentioned below.

Input.

1) /ss/abc/1/w/s/domainname/abc1/logname/
########error###################
########error###################
########error###################
2)/ss/abc/1/w/s/domainname/abc1/logname/
3)/ss/abc/1/w/s/domainname/abc1/logname/
4)/ss/abc/1/w/s/domainname/abc1/logname/
########error#######################
5)/ss/abc/1/w/s/domainname/abc1/logname/

Output

header1  h2      h3     h4   h5    h6            h7     h8       error
ss       abc     1      w    s     domainname    abc1   logname  ###err##
 
ss       abc     1      w    s     domainname    abc1   logname

Here is a Bourne script, someone who knows awk may write something more elegant, I'm not sure if your output of only two lines is intentional, I have taken that as not intentional and assumed that you want the lines with a number at the beginning but you only want the error lines mentioned once in conjunction with the preceding numbered Line.

I made the input file contain a different abc number per line so that we can prove which lines have been displayed:

cat record_files.txt
1) /ss/abc/1/w/s/domainname/abc1/logname/
########error###################
########error###################
########error###################
2)/ss/abc/1/w/s/domainname/abc2/logname/
3)/ss/abc/1/w/s/domainname/abc3/logname/
4)/ss/abc/1/w/s/domainname/abc4/logname/
########error#######################
5)/ss/abc/1/w/s/domainname/abc5/logname/
$

The script is:

$ cat record_files.sh
#!/bin/sh

SAVEDLINE=""
echo "header1\th2\th3\th4\th5\th6\t\th7\terror"
while read LINE; do

  ERRORTEST=`echo "${LINE}" | awk -F"/"  '{ print $1 }' | grep "##error##"`
  BRACKETTEST=""
  if [ -n "${ERRORTEST}" -a -n "${SAVEDLINE}" ]; then
    echo "${SAVEDLINE}\t###err##"
    SAVEDLINE=""
  elif [ -n "${SAVEDLINE}" ]; then
    echo "${SAVEDLINE}"
    SAVEDLINE=""
  else
    BRACKETTEST=`echo "${LINE}" | awk -F"/"  '{ print $1 }' | grep ")"`
  fi

  if [ -n "${BRACKETTEST}" ]; then
    SAVEDLINE=`echo "${LINE}" | awk -F"/"  '{ print $2 "\t" $3 "\t" $4 "\t" $5 "\t" $6 "\t\t" $7 "\t" $8 }'`
  fi

done < record_files.txt

if [ -n "${SAVEDLINE}" ]; then
  echo "${SAVEDLINE}"
fi
$

Here is a run of the script:

$ ./record_files.sh
header1    h2    h3    h4    h5    h6            h7      error
ss         abc   1     w     s     domainname    abc1    ###err##
ss         abc   1     w     s     domainname    abc2
ss         abc   1     w     s     domainname    abc4    ###err##
ss         abc   1     w     s     domainname    abc5
$ 

If my assumptions are wrong then please say so...

Hi Tony,

Thanks a ton for your help.
Actually I am getting a log file every day. From that log file i am taking the errors and sending a mail . Now i want to send the errors in a user friendly format.

logfiles=`find /net/$1/logs -mtime 0 -name os.log |egrep -v archive`;
errStr="ERROR"
newErrFile="$1_temp.log"
rm -f $newErrFile
for logfile in $logfiles ; do
if [[ -s $logfile ]] then
print "\n\n******* $logfile ********\n" >> $newErrFile
perl cer.pl $logfile $errStr >> $newErrFile
fi
done

Now i want to generate user friendly format for newErrFile which is like this

/abc/aa/cc/dd/ee/ff/gg/hh/

/abc/bb/cc/dd/ee/ff/gg/hh

/abd/bb/cc/dd/ee/ff/gg/hh

###errorr###
####multiple lines of error(for some records no error)

again the records.