Question: Need help with an Awk Script, using only awk . We cannot use bash, sed, perl, python or any other language/ utilities I only need
Need help with an Awk Script, using only awk. We cannot use bash, sed, perl, python or any other language/ utilities
I only need to code two scripts using Awk (news.awk and newsfeed.awk)
| News Commands Awk Script ( news.awk ) You have set up a news server and your feed has just sent you his active file. Rather than typing and executing the commands on an individual basis, you decide to write an awk script to create from the active file a file consisting of the necessary addgroup commands. You then plan to execute the file containing the addgroups.
| |||||||
| News Server Usage Script ( newsfeed.awk ) Your news server is now up and running and you wish to view a summary of the amount and type of news traffic being fed to your news server. In particular, for each feed site, you want to see how many articles were accepted, canceled, or rejected.
| |||||||
| Script Execution Your scripts should be invoked directly via the command line, as seen in the following examples: Example: $ awk -f news.awk active > news.commands $ awk -f newsfeed.awk news | |||||||
| Script Files Your program should consist of exactly two files:
|
These two files (active.txt & news.txt) we don't edit, we use them to run them with our .awk scripts
| active.txt |
| general 0000000882 00881 y news.announce.newusers 0000000842 00832 m control 0000252632 251306 y junk 0000043282 43283 y utsa.test 0000000628 00623 y comp.arch 0000028934 28874 y comp.os.minix 0000010172 10162 y comp.sources.unix 0000000831 00832 m comp.sources.misc 0000003228 03229 m comp.sources.games 0000000672 00673 m comp.graphics 0000040657 39618 y comp.lang.c 0000065086 64732 y comp.std.unix 0000001140 01141 m comp.parallel 0000007706 07702 m comp.sources.x 0000001138 01127 m comp.archives 0000010396 10397 m comp.sources.sun 0000000016 00017 m comp.text.tex 0000045350 45148 y comp.ai 0000013920 13874 y comp.ai.edu 0000001661 01658 y comp.ai.neural-nets 0000014649 14586 y comp.ai.nlang-know-rep 0000000196 00197 m alt.text.dwb 0000000271 00263 y alt.thrash 0000007822 07268 y alt.tla 0000000571 00556 y alt.toolkits.xview 0000002830 02731 y alt.tv.muppets 0000007502 07016 y alt.tv.prisoner 0000006453 05941 y alt.tv.simpsons 0000027993 25525 y alt.tv.tiny-toon 0000014878 14479 y alt.tv.twin-peaks 0000015886 14698 y alt.usage.english 0000035572 32641 y ba.announce 0000001320 01189 m ba.food 0000016379 14988 y ba.general 0000017873 16609 y ba.internet 0000003577 02902 y ba.market.computers 0000026518 23654 y ba.market.housing 0000014473 13307 y ba.market.misc 0000032150 29382 y ba.market.vehicles 0000015226 13858 y ba.motss 0000008005 07167 y ba.mountain-folk 0000001830 01505 y bionet.molbio.proteins 0000002136 01814 y bionet.neuroscience 0000003659 03277 y bionet.population-bio 0000000494 00446 y bionet.sci-resources 0000000807 00775 m bionet.software 0000007611 07160 y bionet.users.addresses 0000001457 01357 y biz.clarinet.sample 0000008365 08121 y biz.clarinet 0000000128 00110 y biz.comp.hardware 0000004643 03240 y biz.comp.services 0000002309 01772 y biz.comp.software 0000002127 01602 y biz.comp.telebit 0000002242 02102 y biz.config 0000000235 00143 y misc.misc 0000012110 11529 y misc.news.southasia 0000002199 02083 m misc.rural 0000009695 08570 y misc.taxes 0000013555 12757 y misc.test 0000052731 47912 y misc.wanted 0000025371 24141 y rec.aquaria 0000036116 33065 y rec.arts.animation 0000020290 18964 y rec.arts.anime 0000103930 95127 y rec.arts.bodyart 0000018661 16451 y rec.arts.books 0000082745 76523 y rec.arts.cinema 0000000266 00266 m rec.arts.dance 0000007017 06051 y rec.arts.disney 0000046751 40344 y rec.arts.drwho 0000042003 36588 y rec.arts.fine 0000006356 05628 y rec.arts.int-fiction 0000004498 04185 y rec.arts.misc 0000001388 01280 y rec.arts.movies 0000137329 123389 y |
| news.txt |
| Feb 13 21:28:38.409 + news.cais.net swrinde.nde.swri.edu sun.cais.com the-college.iwctx.edu news.trinity.edu flowsum.channel! overview Feb 13 21:28:38.409 - swrinde 437 Unwanted newsgroup "alt.cracks" Feb 13 21:28:39.179 + news.cais.net swrinde.nde.swri.edu sun.cais.com the-college.iwctx.edu news.trinity.edu flowsum.channel! overview Feb 13 21:28:39.634 + news.cais.net swrinde.nde.swri.edu sun.cais.com the-college.iwctx.edu news.trinity.edu flowsum.channel! overview Feb 13 21:28:39.894 + news.cais.net swrinde.nde.swri.edu sun.cais.com the-college.iwctx.edu news.trinity.edu flowsum.channel! overview Feb 13 21:28:40.187 + news.cais.net swrinde.nde.swri.edu sun.cais.com the-college.iwctx.edu news.trinity.edu flowsum.channel! overview Feb 13 21:28:40.829 + news.cais.net swrinde.nde.swri.edu sun.cais.com the-college.iwctx.edu news.trinity.edu flowsum.channel! overview Feb 13 21:28:41.202 + news.cais.net |
Output of newsfeed.awk script 1 Incoming News Feed Summary 2 canceled 3 4 5 accepted 94755 14374 swrinde : news.cais.net: ?: rejected 19683 240 0 0 6 3 0 3 7 8 Start Time Feb 13 21:28:38.409 End Time Feb 14 20:56:49.066 Output of newsfeed.awk script 1 Incoming News Feed Summary 2 canceled 3 4 5 accepted 94755 14374 swrinde : news.cais.net: ?: rejected 19683 240 0 0 6 3 0 3 7 8 Start Time Feb 13 21:28:38.409 End Time Feb 14 20:56:49.066
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
