Using the awk command in Unix. I need to manipulate raw data with course numbers
ID: 3595419 • Letter: U
Question
Using the awk command in Unix.
I need to manipulate raw data with course numbers and 9 digit employee numbers at the end like the following two examples.
Fall 2017 COMM 438T-01 21785 888972491
Summer 2017 MSW 571-40 11230 890248716
I'm trying to produce a listing which is grouped by season (fall and summer) and ordered by class number(the numbers around the dash) and then section number(the 5 digit number) in descending order. Then a count for the amount of Fall and Summer groups. I have the awk command and scripting as tools to do this.
The listing is supposed to only include lines with the 9 digit employee number.
I try to use awk '/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/{print " "$0""$1""$2""$3" "$4" "$5""$6""$7""$8""$9}' a.txt | sort
but for some reason it seems to merge a couple lines together, i have lines that are twice the size as they were before but that was not my intent.
Explanation / Answer
awk '{season=$1; class=$4;section=$5;en=$NF; if (season in sh)sh[season]=sh[season] " "
season " " class " " section; else sh[season]=season " " class " " section;}END{for(season in sh)
print sh[season];}' givenFile
Explanation:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.