Linux awk advanced application instance _linux shell

Source: Internet
Author: User

Today to see the Unix shell example fine solution on the Youdao awk on the topic after doing it to share with you

Pre-processing documents:

Mike Harrington: (510) 548-1278:250:100:175
Christian Dobbins: (408) 538-2358:155:90:201
Susan Dalsass: (206) 654-6279:250:60:50
Archie McNichol: (206) 548-1348:250:100:175
Jody Savage: (206) 548-1278:15:188:150
Guy Quigley: (916) 343-6410:250:100:175
Dan Savage: (406) 298-7744:450:300:275
Nancy McNeil: (206) 548-1278:250:80:75
John Goldenrod: (916) 348-4278:250:100:175
Chet Main: (510) 548-5258:50:95:135
Tom Savage: (408) 926-3456:250:168:200
Elizabeth Stachelin: (916) 440-1763:175:75:300

The results required are as follows:
CAMPAIGN 1998 contributions***

Name PHone |   Feb |   MAR | Total donated
---------------------------------------------------------------------------------

Mike Harrington (510) 548-1278 250 100 175 525
Christian Dobbs (408) 538-2358 155 90 201 446
Susan Dalsass (206) 654-6279 250 60 50 360
Archie McNichol (206) 548-1348 250 100 175 525
Jody Savage (206) 548-1278 15 188 150 353
Guy Quigley (916) 343-6410 250 100 175 525
Dan Savage (406) 298-7744 450 300 275 1025
Nancy McNeil (206) 548-1278 250 80 75 405
John Goldenrod (916) 348-4278 250 100 175 525
Chet Main (510) 548-5258 50 95 135 280
Tom Savage (408) 926-3456 250 168 200 618
Elibeth Stachel (916) 440-1763 175 75 300 550

SUMMARY
-----------------------------------------------------------------------------------
The Campan received atotal of $6137 for this quarter
Average donation for the contributors is $511.417.
The highest contribution was $450.
The lowest contribution was $.

The code is as follows:

Begin{fs= ":"; low1=300;low2=400;low3=500 ofs= "\ T" Print \t\t***campaign 1998 contributions***\n "Print"----- ----------------------------------------------------------------------------\ n "Print" Name\t\t\tphone\t\t\tjan | \tfeb |\tmar |\ttotal donated "print"----------------------------------------------------------------------------- ----\ n} {tot=$3+$4+$5} {Ttot+=tot} {print $, \ t $ \t\t "$" \ T "$" \ T "$" \ T "tot} {AVG=TTOT/12} {high1= (high1> $)? High1:$3} {high2= (high1>$4)? High1:$4} {high3= (high1>$5)? High1:$5} {max12= (HIGH1&GT;HIGH2)? HIGH1:HIGH2} { max23= (HIGH2&GT;HIGH3)? High2:high3} {max= (max12>max23)? max12:max23} {low1= (low1<$3)? Low1:$3} {low2= (Low1 <$4)? low1:$4} {low3= (low1<$5) low1:$5} {min12= (low1<low2)? Low1:low2} {min23= (LOW2&LT;LOW3)? Low2:low3} { Min= (min12<min23) min12:min23} end{print "------------------------------------------------------------------- ----------------"print" \t\tsummary "print"-----------------------------------------------------------------------------------"printf" the Campan received Atotal of $ ";p RI NTF Ttot; print ' For this quarter ' printf ' average donation for the ' contributors was $ ';
    printf avg;p rint "."
    printf "The highest contribution was $";p rintf max;print "." 
printf "The lowest contribution was $";p rintf min;print "." }
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.