printing the content from a file

hi ,
i m new to unix and i don no how to print this format
i have output file like

THE DOMAIN NAME VPORCL01 FOR THE HOSTNAME Ram-pc
Port=1533
Port=9000
Listener Port=9100

THE DOMAIN NAME VPORCL02 FOR THE HOSTNAME Ram-pc
Port=7000
Port=9000
Listener Port=9100

but i sholud print output this format

instance name WSL port JSL port JRAD port

VPORCL01 1533 9000 9100

VPORCL02 7000 9000 9100

can any one help ...thanks in advance

with regards,

ram

Try this...

cat <input-file> | egrep "VPORCL|Port" | sed 's/THE DOMAIN NAME //g' | paste - - - -

---------- Post updated at 08:01 PM ---------- Previous update was at 07:52 PM ----------

This would be more clear

cat <input-file> | egrep "VPORCL|Port" | sed 's/THE DOMAIN NAME //g;s/Port=//g;s/Listener//g;s/FOR THE HOSTNAME Ram-pc//g' | paste - - - -

This shall be clear, input file is temp_file

 
X=0
Y=0
cat -n temp_file | grep VPORCL | awk '{print $1}' > temp_head
while read line
do
arr_head[$X]=$line
X=`expr $X + 1`
done < temp_head
cat -n temp_file | grep "Listener Port" | awk '{print $1}' > temp_tail
while read line
do
arr_tail[$Y]=$line
Y=`expr $Y + 1`
done < temp_tail
n=0
while [ $n -lt $Y ]
do
var1=`echo ${arr_head[$n]}`
var2=`echo ${arr_tail[$n]}`
sed -n "${var1},${var2}p" temp_file > tmp_part_file
instance=`cat tmp_part_file | sed -n "1p" | awk '{print $4}'`
WSL=`cat tmp_part_file | sed -n "2p"  | awk -F"=" '{print $2}'`
JSL=`cat tmp_part_file | sed -n "3p"  | awk -F"=" '{print $2}'`
JRAD=`cat tmp_part_file | sed -n "4p"  | awk -F"=" '{print $2}'`
echo $instance $WSL $JSL $JRAD
n=`expr $n + 1`
done

hi
thanxs for ur reply..... i have formatted the output now the file looks like this
VPORCL01
Ram-pc
1533
9000
9100

VPORCL02
Ram-pc
7000
9000
9100
now ,
i need to print this out put in this format

VPORCL01 Ram-pc 1533 9000 9100
VPORCL02 Ram-pc 7000 9000 9100

X=0
Y=0
cat -n temp_file | grep VPORCL | awk '{print $1}' > temp_head
while read line
do
arr_head[$X]=$line
arr_tail[$Y]=`expr ${arr_head[$X]} + 4`
X=`expr $X + 1`
Y=`expr $Y + 1`
done < temp_head
n=0
while [ $n -lt $Y ]
do
var1=`echo ${arr_head[$n]}`
var2=`echo ${arr_tail[$n]}`
sed -n "${var1},${var2}p" temp_file > tmp_part_file
instance=`cat tmp_part_file | sed -n "1p"`
Ram=`cat tmp_part_file | sed -n "1p"`
WSL=`cat tmp_part_file | sed -n "2p"`
JSL=`cat tmp_part_file | sed -n "3p"`
JRAD=`cat tmp_part_file | sed -n "4p"`
echo $instance $Ram $WSL $JSL $JRAD
n=`expr $n + 1`
done

awk:

echo 'instance name WSL port JSL port JRAD port'; echo ""
awk '/^THE/ {printf("%s\t", $4); next}
     /=/ { gsub( /.*=/, "", $0); printf("%s\t", $0); next}
     /^$/ {printf("\n")}
    ' filename

output:

/home/jmcnama> t.awk
instance name WSL port JSL port JRAD port

VPORCL01        1533    9000    9100

VPORCL02        7000    9000    9100

thanks for all , its working fine :wink:

nawk 'BEGIN{RS="";FS="\n"}{
split($1,arr," ")
printf("%s ",arr[4])
for(i=2;i<=NF;i++)
{
sub(/.*=/,"",$i)
printf("%s ",$i)
}
print ""
}' yourfile