I have a file laid out like this
gender,yearsExperience,yearsSchool,wage female,9,13,6.3152956461 female,12,12,5.4797699786 female,11,11,3.6421699174 female,9,14,4.5933365997 female,8,14,2.4181574607
I am trying to find the difference between the minimum wage earned by high school and college grads (12/16 yearsSchool). I have a shell script written as follows:
#High School Min HighSchoolMin=$(cat wages.csv | cut -d "," -f 3,4 | egrep "^[1]{1}[2]{1}," | tr , " " | sort -k2,2r | tail -n 1 | cut -d " " -f 2) #College Min CollegeMin=$(cat wages.csv | cut -d "," -f 3,4 | egrep "^[1]{1}[6]{1}," | tr , " " | sort -k2,2r | tail -n 1 | cut -d " " -f 2) Difference=$($CollegeMin-$HighSchoolMin | bc) echo The difference in minimum wages between high school and college graduates is $Difference.
when i bash this.script
i get line 13: 10.128063739-0.1028907398: command not found
I think this is because the variables are being considered strings not numerical values. I have tried declare -i
but that does not work because of the decimal places, and I need an exact answer.
Does anyone know of any workarounds? am i on the right track or is there just a fundamental issue in how i'm going about this?