Question: Unix If else awk script - I have a file called iclassroster which has the following data: Last Name : First Name : Student ID
Unix If else awk script - I have a file called "iclassroster" which has the following data:
Last Name : First Name : Student ID : Program & Plan : Academic Level : ASURITE : Email
Alvarado : Anthony : 1209480997 : Ira A Fulton Engineering - Information Technology : Senior : aalvar33 : aalvar33@asu.edu
Alvarez : Gibran : 1201390350 : Ira A Fulton Engineering - Information Technology : Junior : galvare2 : galvare2@asu.edu
Angus : Glen : 1000746988 : Ira A Fulton Engineering - Information Technology : Junior : gangus : gangus@asu.edu
Ashby : Cole : 1207146326 : Ira A Fulton Engineering - Information Technology : Senior : cashby : cashby@asu.edu
Bailey : Allan : 1000548822 : Ira A Fulton Engineering - Information Technology : Senior : asu41981 : asu41981@asu.edu
Barron : Rudy : 1208428789 : Ira A Fulton Engineering - Information Technology : Junior : rrbarron : rrbarron@asu.edu
Box : Jeffrey : 1208427112 : Ira A Fulton Engineering - Information Technology : Post-Bacc Undergraduate : jabox1 : jabox1@asu.edu
Burden : Nicholas : 1206996878 : Ira A Fulton Engineering - Information Technology : Senior : nbburden : nbburden@asu.edu
Camiliere : Kurtis : 1200663364 : Ira A Fulton Engineering - Information Technology : Senior : kcamilie : kcamilie@asu.edu
Camp : Michael : 1000830925 : Ira A Fulton Engineering - Information Technology : Senior : mcamp1 : mcamp1@asu.edu
Carleton : Robert : 1000727027 : Ira A Fulton Engineering - Information Technology : Junior : rcarleto : rcarleto@asu.edu
Cartwright : Dustin : 1001460822 : Ira A Fulton Engineering - Tech Entrepreneurship & Mgmt : Senior : dbcartwr : dbcartwr@asu.edu
Cook : John : 1201860560 : Ira A Fulton Engineering - Information Technology : Senior : jrcook7 : jrcook7@asu.edu
Debiasio : Thomas : 1207331615 : Ira A Fulton Engineering - Software Engineering : Post-Bacc Undergraduate : tdebiasi : tdebiasi@asu.edu
Dixon : Jason : 1208487705 : Ira A Fulton Engineering - Software Engineering : Junior : jadixon5 : jadixon5@asu.edu
Fernandez : Jose : 1207627963 : Ira A Fulton Engineering - Information Technology : Post-Bacc Undergraduate : jlferna4 : jlferna4@asu.edu
Hale : Hunter : 1207103803 : Ira A Fulton Engineering - Information Technology : Junior : hehale : hehale@asu.edu
Heisey : Thane : 1207033252 : Ira A Fulton Engineering - Information Technology : Junior : theisey : theisey@asu.edu
Hoyle : Jeremy : 1000527662 : Ira A Fulton Engineering - Information Technology : Junior : jhoyle : jhoyle@asu.edu
Jardine : Parker : 1201654029 : Ira A Fulton Engineering - Information Technology : Post-Bacc Undergraduate : pjardine : pjardine@asu.edu
Johnson : Joshua : 1000745321 : Ira A Fulton Engineering - Information Technology : Junior : jrjohnso : jrjohnso@asu.edu
Kone : Chinmingnon : 1207997618 : Ira A Fulton Engineering - Information Technology : Junior : cdkone : cdkone@asu.edu
I need to create an If Else awk script to count the following: How many times does Information Technology occur? How many Freshmen there are? How many Sophmore there are? How many Juniors there are? How many Seniors there are? How many Post-Bacc Undergrads there are? and output this info to the screen.
So far I only have this and needs some help tooling my script to work for all the questions one after the other in an If elseif else structure. Please help I know it needs alot of work, but I have been tinkering with it for 2 days now. the letters were my count variables.
while read -r iclassroster _; do A=0 IT="Information" B=0 FR="Freshman" C=0 JU="Junior" D=0 SO="Sophmore" E=0 SE="Senior" F=0 PBU="Post" if [ "Information" = "$iclassroster" ]; then ((A++)) | echo $A fi done
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
