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 @@
Garden State
The Princess Bride
LaLa Land
Across the Universe
The Great Gatsby
Interstellar
5 changes: 5 additions & 0 deletions gender-yearsExperience.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#sort wages.csv by gender then years experience

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.

When provided, comments in code are descriptive. Please comment code consistently across script.
Work on providing more descriptive commit messages for collaborators and future you :)

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.

2.5/3

#usage bash gender-yearsExperience

cat wages.csv | cut -f 1,2 -d "," | sed 's/,/ /g' | sort -k 1,1d -k 2,2n

@mdoellma mdoellma Oct 6, 2017

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.

Please read the questions carefully before finishing. Missing uniq at the end of the pipeline. Results should be written to a file.
-0.25 pts


31 changes: 31 additions & 0 deletions wagesAnalysis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
### Script for getting information about highest and lowest earning people
### Usage: bash wagesAnalysis.sh

#
echo "Highest earner:"
### Gets the gender, yearsExperience, and wages of the highest earner
cat wages.csv | sed 's/,/ /g' | sort -k 4 -n | tail -1 | cut -d " " -f1,2,4

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!

#
echo "Lowest earner:"
### Gets the gender, yearsExperience, and wages of the lowest earner
cat wages.csv | sed 's/,/ /g' | sort -k 4 -n | head -2 | grep -v "gender" | cut -d " " -f1,2,4

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!

#
echo "Number of females in the top 10 earners:"
cat wages.csv | sed 's/,/ /g' | sort -k 4 -n | grep -v "gender" | head -10 | cut -d " " -f1,2,4 | 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.

This gives the number of females in the bottom 10. Either use tail -10 or the -r flag in sort.
-0.25 pts


#
echo "Average wage of those with 12 years school:"
cat wages.csv | cut -d "," -f 3,4 | grep "12," | sed 's/,/ /g' | awk '{ sum += $2; n++ } END { if (n > 0) print sum / n; }'

#
echo "Average wage of those with 16 years school:"
cat wages.csv | cut -d "," -f 3,4 | grep "16," | sed 's/,/ /g' | awk '{ sum += $2; n++ } END { if (n > 0) print sum / n; }'

#
echo "Difference in wage:"
VAR1="$(cat wages.csv | cut -d "," -f 3,4 | grep "16," | sed 's/,/ /g' | awk '{ sum += $2; n++ } END { if (n > 0) print sum / n; }')"
VAR2="$(cat wages.csv | cut -d "," -f 3,4 | grep "12," | sed 's/,/ /g' | awk '{ sum += $2; n++ } END { if (n > 0) print sum / n; }')"

echo "$VAR1 - $VAR2" | bc

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.

I think the question was asking for the difference in minimum wage between genders, but average is OK. Kudos for incorporating awk!