#!/bin/sh
if [ "x$1"=="x" ] ; then 
  echo "Usage: up_bb <postscript file>" 
  echo "  Moves last bounding-box line to the top of the file"
  echo "  By this , makes postscript produced by GMT (with BBox at end)"
  echo "   usable for LaTeX epsf package "
  echo "  (c) xray.sai.su.su/~ivan " 
  exit
fi

BB=`grep '%%BoundingBox:' $1 | tail -1 `
HEAD=`head -1 $1`
TMP=/tmp/up_bb.$$
cp $1 $TMP
echo $HEAD >$1
echo $BB >> $1
cat $TMP >> $1
rm -f $TMP
