Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Exercise4A.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
grep -w "female" wages.csv | cut -d , -f1,2 | tr ',' ' ' | sort -n -k2 | uniq >> Wages1.txt
grep -w "male" wages.csv | cut -d , -f1,2 | tr ',' ' ' | sort -n -k2 | uniq >> Wages1.txt

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.

Alternatively, you can sort by the first column and then the second column with command sort:
sort -k1,1d -k2,2n

5 changes: 5 additions & 0 deletions Exercise4C.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#for input, go with the higher numbered term first and only using the format gender,yearsOfschooling, for example, "male,16" or "female,16"
a=$(cut -d , -f1,3,4 wages.csv | grep -we "$1" | cut -d , -f3 | sort -rn | tail -n 1)
b=$(cut -d , -f1,3,4 wages.csv | grep -we "$2" | cut -d , -f3 | sort -rn | tail -n 1)
echo "$a-$b" | bc

33 changes: 33 additions & 0 deletions Wages1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
female 1
female 2
female 3
female 4
female 5
female 6
female 7
female 8
female 9
female 10
female 11
female 12
female 13
female 14
female 15
female 16
male 2
male 3
male 4
male 5
male 6
male 7
male 8
male 9
male 10
male 11
male 12
male 13
male 14
male 15
male 16
male 17
male 18
15 changes: 15 additions & 0 deletions exercise4B.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#To return the gender, yearsExperience, and wage of the lowest earner to stdout

#To return the genfer, yearsExperience, and wage of the lowest earner to stdout

#To return number of female wage earners to stdout

var1=$(cat $filename | sort -k4 -n | cut -d ',' -f1,2,4 | head -n 2 | tail -n 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.

Sort doesn't work with csv format. You may want to replace "," with " " first:
cat wages.csv | grep -v "gender" | tr "," " " | sort -n -k 4 | tail -n 1 | cut -d " " -f 1,2,4 | tr " " ","

-0.25 point

var2=$(cat $filename | sort -k4 -n -g | cut -d ',' -f1,2,4 | tail -n 1)
var3=$(cat $filename | sort -k4 -n -g | cut -d ',' -f1,2,4 | tail -n 10| grep -w "female" | wc -l)
echo $var1 $var2 $var3





7 changes: 7 additions & 0 deletions movies.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Good Will Hunting
Shawshank Redemption
Interstellar
Godfather 1/2
Remember the Titans
Elf