ShaneUniStudent 0 Newbie Poster

Hey guys, i am a noobie and i am after some very much anticipated help. I currently attend uni and working on a project for a subject called unix based engineering. The basic problem is; I have an input file and this input file contains a series of MOSFET parameters like saturation currents or whatever, and this program needs to be executed into a program called MINI2D which then creates an output file. From the input file we can then do some simple pattern matching to find /BIAS/ for bias voltage and from the output file we can find /DRAIN CURRENT/ for the drain current. After retrieving the data from the output file we can then generate a file with a list of voltages versus currents which can be plotted using GNUPLOT. The user enters a start voltage, end voltage, step size and input filename from command line arguments. The part where i am having the most difficulty with is, i have a while loop which basically says while start = $1 and is lessthen or equal to $2 then look in the input file for BIAS and store the value , look in the output file and store the value for DRAIN CURRENT. Now in order to get a list of voltages versus currents i need to increment the start voltage by the step size and replace into the input file, run through MINI2D once again and retrieve the drain current, etc. Doing this until the while loop becomes the end. I am having major problems with the incrementing part. I am trying to utilise AWK to add the step size to the start size and then continue through the loop. I am a little stuck and need some urgent help :) This is what i have so far.

#!/bin/bash


echo -e "Setting start voltage of $1 volts"
START=$1


echo -e "Setting stop voltage of $2 volts"
STOP=$2


echo -e "Setting step size of $3 volt increments"
STEP=$3


echo -e "Reading $4 from user...."


if [ -r $4.inp ]        #Checks if input file exists and is readable
then
cat "$4.inp" > fort.15      #If true then concatonate > fort.15
else
echo -e "ERROR: File doesnt exist!!"
fi


while [ $STEP -le $STOP ];do


BV=`awk '/BIAS/{print $3}' $4.inp`     #looks through input file and retrieves value
DC=`awk '/DRAIN CURRENT/{print $4}' $4.out`  #retrieves value from output file


echo -e "The BIAS voltage is $BV"
echo -e "The DRAIN CURRENT is $DC"

All i need to do now is place those retrieved values into a file, increment the step, run through mini2d again, retrieve output until $STEP > $STOP.

Im sorry if this doesnt make sense, i realise its quite a simple problem however i have almost given up on it since i just cannot get awk to work nicely. If you would like to see the actual question or my whole shell script just message me. Thanks heaps and heaps