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.

  1. The lines in the active file have the following format:

    comp.os.linux.announce 0000002587 02190 m
    comp.arch 0000028934 28874 y
    utsa.cs.2413 0000000004 0000000001 y
  2. Each line in the active file should be converted to an addgroup command. For example, the previous three lines should generate the following commands: addgroup comp.os.linux.announce m addgroup comp.arch y

    addgroup utsa.cs.2413 y

  3. The awk script must be in a file named news.awk, and you should be able to run the conversion with the following command: awk -f news.awk active > news.commands

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.

  1. Make the following symbolic link in your assign3 directory using the following commands:

    ln -s /usr/local/courses/ssilvestro/cs3424/Spring21/assign3ews news

  2. The news distribution daemon, innd, will write one line for each article in the news file. This is a

    text file with a variable number of space-separated fields in one of the following formats:

    mon dd hh:mm:ss.mmm + feed site...

    mon dd hh:mm:ss.mmm j feed site...

    mon dd hh:mm:ss.mmm c feed site...

    mon dd hh:mm:ss.mmm - feed site...

    The first three fields are the date and time to millisecond resolution. The fifth field is the site that sent the article (based on its path header), and the sixth field is the articles Message-ID; there will be a question mark if the information is not available.

    The fourth field indicates whether the article was accepted or not. If it is a plus sign, then the article was accepted. If it is the letter j then the article was accepted, but filed in the junk newsgroup. If the fourth field is the letter c then a cancel message was accepted before the original article arrived. In all three cases, the article has been accepted and the site... field contains a space-separated list of sites to which the article is being sent.

    If the fourth field is a minus sign then the article was rejected.

  3. Your news server has the following feeds:

    swrinde
    news.cais.net
    ?
  4. Calculate the following information for each feed: / The number of articles accepted from each site. / The number of articles rejected from each site. / The number of articles canceled from each site.

  5. The date and time of the first entry as well as the last entry should also be printed. The news file represents one day of traffic.

  6. Because the news file is quite large, you may want to use sed to create a smaller file of approximately 1,000 lines on which to test your program.

  7. This awk scripts filename should be titled as newsfeed.awk.

  8. The output should be formatted as closely as possible to the following:

Need help with an Awk Script, using only awk. We cannot use

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:

news.awk - awk script responsible for parsing and reformatting the active data file

newsfeed.awk - awk script responsible for parsing the news data file

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 swrinde.nde.swri.edu sun.cais.com the-college.iwctx.edu news.trinity.edu flowsum.channel! overview Feb 13 21:28:41.327 - swrinde 437 Unwanted newsgroup "alt.binaries.sounds.tv" Feb 13 21:28:41.575 - swrinde 437 Unwanted newsgroup "alt.binaries.sounds.tv" Feb 13 21:28:41.608 + 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.871 + news.cais.net swrinde.nde.swri.edu sun.cais.com the-college.iwctx.edu news.trinity.edu flowsum.channel! overview Feb 13 21:28:42.148 + news.cais.net swrinde.nde.swri.edu sun.cais.com the-college.iwctx.edu news.trinity.edu flowsum.channel! overview Feb 13 21:28:42.380 + news.cais.net swrinde.nde.swri.edu sun.cais.com the-college.iwctx.edu news.trinity.edu flowsum.channel! overview Feb 13 21:28:42.549 - swrinde 437 Unwanted newsgroup "alt.binaries.sounds.tv" Feb 13 21:28:42.728 + news.cais.net swrinde.nde.swri.edu sun.cais.com the-college.iwctx.edu news.trinity.edu flowsum.channel! overview Feb 13 21:28:43.000 + swrinde swrinde.nde.swri.edu the-college.iwctx.edu news.trinity.edu flowsum.channel!

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!