# This outputs a page ($1) of 66 lines

lines=66
rnum=`expr $1 \* $lines`

echo "${rnum} -${lines}+1;${rnum} p|ed - $2

exit

#The following gets the error messages from each individual section and
#creates a file<x> with the error messages from that section

line2="/^\.H [123]/;/^\.H [123]/ -1 p"
for hline in `count 0 16`
do
        line="$line/^\.H [123]/;/^\.H [123]/ -2 d\n"
echo $line LINE $line2 LINE2
        echo $line$line2|ed - appmma_E > file${hline}
        echo "###### done $hline"
done

exit

# gives the second to the last line
echo "1,$ -2 d\np"|ed - $0

exit

# This gives everything AFTER the line "linex" EXCEPT the last line.

ed - tstfile <<-!
/^linex/+1;$ -1 p
!

exit

#This take <$line> joins it with the next line and adds a " to the end

ed - tmpfile.$$ <<-!
/$line/ s/\"$/ /
.,.+1 j
. g/\.aM/ s/$/"/p
!

exit

ed - $1 <<-!
g/T{$/ s/T{//
.,.+1 j
g/T}/ s/T}//
.-1,. j
w
q
!
# This globally changes every instance of $1 to $2 in $file

ed - $file <<-!
g/$1/ s/$1/$2/
w
q
!
exit

table=EST
ed $1 <<-! > tmpEST
/^\.H.* "$table /;/^\.TE/ p
!
#cat tmpEST

ed - tmpEST <<-!
/T{$/
.,.+1 j
/T}/
.-1,. j
w
q
!
exit

line2="/^<TABLE/;/^<TABLE/ -1 p"
max=`grep -c "^<TABLE" $1`
for hline in `count 1 $max`
do
cat <<-EOF > file${hline}
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html">
</HEAD>
<BODY>
EOF
	if [ "$hline" -eq "$max" ]
	then
		line2="/^<TABLE/;$ -1 p"
	fi
	echo $line$line2|ed - $1 >> file${hline}
	echo "###### done $hline"
	line="$line/^<TABLE/;/^<TABLE/ -2 d\n"
echo "</BODY>" >> file${hline}
done

exit

for table in `grep "Contract Definition<" IDS.html|
sed -e "s/Contract Def.*$//" -e "s/^.*<P>//"|
sed -e "s/^LMID//" -e "s/^IDLM//" -e "s/X//g"`
do
ed - IDS.html <<-! |egrep -v ">Field<|>Description<"|sed "s/.*<P>\(.*\)<\/FONT>.*$/\1/"
/$table.*Contract Definition/ p
/^<TABLE/;/^<\/TABLE>/ g/FONT FACE/ p
!
done
exit
/^<table/;/^<\/table>/ g/FONT FACE/ p
ed - IDS.html <<-! |egrep -v ">Field<|>Description<"

exit

table=CEST
flength=`wc -l $table|awk '{print $1}'`
glength=`expr $flength / 3`
#echo $glength

for number in `count 1 $glength`
do
ed - $table <<-!
$number s/$/ /
.,.+1 j
. s/$/ /
.,.+1 j
w
q
!
done

exit

table=EST
field=ENTB
inout=in

if [ "$inout" = "in" ]
then
okay=`ed - MPFCONTR <<-!|grep "^$field"|awk '{print $3}'
/\*\*CONTRACT.*$table/;/\*\*CONTRACT/-1 p
!`
else
okay=`ed - MPFCONTR <<-!|grep "^$field "|awk '{print $4}'
/\*\*CONTRACT.*$table/;/\*\*CONTRACT/ p
!`
fi
echo $okay
exit
okay=`ed - MPFCONTR <<-!|grep "^$field "|awk '{print $3}'
/\*\*CONTRACT.*$table/;/\*\*CONTRACT/ p
!`

exit

#This adds a line to the beginning of a file

ed - $file <<-!
0a
{line to be added}
.
w
q
!
exit
#This adds after the 10th line - note the needed space between 10 and a.
ed - $file <<-!
10 a
{line to be added}
.
w
q
!
exit

#This gives the last .DS - .DE group without printing the .DS or .DE

ed - <file> <<-! >
?\.DS?+1;/\.DE/-1 p
!

#This gets rid of every instance between the two fields
ed - $1 <<-!
1;$ g/^From [TM]*/ .;/Message-Id/d
w
q
!
This gets rid of mail headers
rmhead ()
{
ed - $tmmail <<-!
g/^From [Tt][Mm]/ .;/^$/-1 d
w $tmpmail
q
!
}

#this will only squash the last single blank line
ed - testfile  <<-!
1,$ g/^$/ .+1 s/^$//
.,.+1 j
w
1,$ p
!
exit
#this will eat multiple blank lines and squash single blank lines
ed - testfile  <<-!
1,$ g/^$/ .,.+1 j
w
!
exit

#this substituted one line from doh with one from tmpfile

cat doh|while read line
do
linecln=`echo $line|sed "s#/#.#g"`
output=`grep "$line" tmpfile|sed "s/^{/\.aM /"|sed "s/,$//"`
echo LINE $line
echo OUTPUT $output
ed - ddview_E <<-!
/$linecln/ c
$output
.
w
q
!

These are equivalent.  Prints from (xxx) to (xxx) and whacks the last line:
sed:
        cat /docs/tmwmb/wmb-r1/r1/doc/ov/features|
        sed -n -e "/($num.*)/;/([0-9][0-9].*)/ p"|sed "$ d"
ed:
        ed - /docs/tmwmb/wmb-r1/r1/doc/ov/features <<-!
        /($num.*)/;/([0-9][0-9].*)/-1 p
        !

Used this to add () around docnames in 455-4B.alltools
ed - alltools <<-!
g/[A-z0-9]\{2,\}\.[0-9A-z]\{2,\}/ s/\(.* \)\([A-z0-9_-]\{2,\}\.[0-9A-z_-]\{2,\}\)\( .*\)/\1(\2)\3/p
!
#DON'T FPRGET THE FRIGGIN' DOT AFTER THE aic COMMANDS
