#!/bin/sh

# ucbsim  --  sets the format of an ext2sim-generated SIM file if it's not
#             already set.  the new file is written to stdout.
#
#	      usage:  ucbsim <sim file>
#
# written by harold levy (har@caltech.edu)

if [ $# != 1 ]; then
  echo "usage:  ucb <sim file>"
  exit -1;
fi

if [ ! -f $1 ]; then
  echo "cannot find \"$1\" for input"
  exit -1;
fi

awk '
BEGIN { firstFlag = 0; }

{
  if ( firstFlag == 0 ) {
    firstFlag = 1;
    if ( $0 !~ /.*format.*/ )
      printf ("%s    format: UCB\n", $0);
    else
      printf ("%s\n", $0);
  }
  else
    printf ("%s\n", $0);
}
' $1

