I am trying to use Bourne shell scripting for the first time ever, and I cannot seem to figure out determining how to save text from a file to internal script variables. The file format is as follows:
acc.text
Jason Bourne 213.4
Alice Deweger 1
Mark Harrington 312
The current script that I have (which might be ENTIRELY incorrect as I am simply creating it in NotePad++ without using an actual shell console) is as follows:
#!/bin/sh
process_file()
{
FILE = $1;
SALARYARRAY;
NAMEARRAY;
COUNTER = 0;
while read line
do
$NAMEARRAY[$COUNTER] =
$SALARYARRAY[$COUNTER] =
$COUNTER + 1;
echo $NAMEARRAY[$COUNTER]:$SALARYARRAY[$COUNTER];
done < "$FILE"
order_Map
}
# Function is not complete as of now, will later order SALARYARRAY in descending order
order_Map()
{
i = 0;
for i in $COUNTER
do
if ($SALARYARRAY[
done
}
##
# Main Script Body
#
# Takes a filename input by user, passes to process_file()
##
PROGRAMTITLE = "Account Processing Shell Script (APS)"
FILENAME = "acc.$$"
echo $PROGRAMTITLE
echo Please specify filename for processing
read $FILENAME
while(! -f $FILE || ! -r $FILE)
do
echo Error while attempting to write to file. Please specify file for processing:
read $FILENAME
done
echo Processing the file...
process_file $FILENAME