Skip to content
6 changes: 6 additions & 0 deletions favemovies.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Inception
The Two Towers
Gladiator
The Dark Knight
Dark Knight Rises
Fury
29 changes: 29 additions & 0 deletions gender.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Takes wages.csv and...

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellently commented code! Could use more frequent/useful commit messages.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3/3

#1) removes first row,
#2) only keeps gender and years experience columns,
#3) sorts unique gender/years experience combinations,
#4) and writes it to a filename of your choice

#Usage: bash gender.sh <filenameforoutput>
echo 'Unique gender and yearsexperience cominations saved to' $1
cat wages.csv | sed '1d'| cut -d, -f-1,2 | sort -ut"," -k1,1 -k2n,2 > "$1"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct


#Returns gender, yearsExperience, and wage for
#1 highest earner
#2 lowest earner
#3 number of females in the top 10 wage earners

echo 'highest earner:'
cat wages.csv | grep -v gender | sed 'y/,/ /' | sort -k 4 -n -r | head -n 1
echo 'lowest earner:'
cat wages.csv | grep -v gender | sed 'y/,/ /' | sort -k 4 -n -r | tail -n 1
echo 'number of females in the top 10 wage earners:'
cat wages.csv | grep -v gender | sed 'y/,/ /' | sort -k 4 -n -r | head -n 10 | grep female | wc -l

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, but if you read the directions carefully, you should have deleted the years schooling column from the returned responses.


#demonstrates the effect of graduating college on minimum wage

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kudos for the use of awk! If you read directions carefully, you should have returned minimum, not average wage, but OK.
Should have reported the difference with echo "$val2 - $val1" | bc, after saving college and high school wages to val1 and val2.


#college grad
cat wages.csv | sed 'y/,/ /' | awk '$3 == "16"' | cut -d " " -f 4 | awk '{s+=$1}END{print "average college graduate minimum wage:",s/NR}'

#no college education
cat wages.csv | sed 'y/,/ /' | awk '$3 == "12"' | cut -d " " -f 4 | awk '{s+=$1}END{print "non-college graduate minimum wage:",s/NR}'
3 changes: 3 additions & 0 deletions genderYears.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cat "$1" | sed '1d'| cut -d, -f-1,2 | sort -ut"," -k1,1 -k2n,2 > "$2"