IN LINUX/UNIX 1. Based on the example “awkc7” introduced in the handouts, please write an awk script...

60.1K

Verified Solution

Question

Programming

IN LINUX/UNIX

1. Based on the example “awkc7” introduced in thehandouts, please write an awk script to display the firstsix records in “loginfile.”Please test your script to make sure the script displays thefollowing information:

ics325sp200221pts/6       75.168.197.229   Wed Apr 29 22:09 - 23:27(01:17)    

ics325sp200221pts/10      75.168.197.229   Wed Apr 29 22:04 - 22:07(00:02)    

ics325sp200220pts/10      24.118.187.116   Wed Apr 29 15:28 - 15:30(00:02)    

ics325sp200220pts/10      24.118.187.116   Wed Apr 29 15:22 - 15:23(00:00)    

ics325sp200222pts/11      68.47.45.2       Wed Apr 29 14:54 -22:34 (07:39)    

ics325sp200220pts/10      24.118.187.116   Wed Apr 29 14:52 - 15:08(00:15)  

2. How to modify “awkc7” so that we can display thelast three records in“loginfile?” (you can assume that we have only 7 recordsin “loginfile”). Please test your script so that itdisplays the following information:

ics325sp200222pts/11      68.47.45.2       Wed Apr 29 14:54 -22:34 (07:39)    

ics325sp200220pts/10      24.118.187.116   Wed Apr 29 14:52 - 15:08(00:15)    

ics325sp200221pts/8       75.168.197.229   Wed Apr 29 14:03 - 22:10 (08:07)

3. Based on the example “awkc7” introduced in thehandouts, please write an awk script to display therecords from the third tofifth in “loginfile.” Pleasetest your script to make sure the script displays the followinginformation:

ics325sp200220pts/10      24.118.187.116   Wed Apr 29 15:28 - 15:30(00:02)    

ics325sp200220pts/10      24.118.187.116   Wed Apr 29 15:22 - 15:23(00:00)    

ics325sp200222pts/11      68.47.45.2       Wed Apr 29 14:54 -22:34 (07:39)       

4. As we know, thecommand “df –h” will return the following message:

Filesystem      Size Used Avail Use%Mounted onudev           3.9G 4.0K 3.9G   1% /devtmpfs          799M 800K 798M   1% /run/dev/dm-0        97G  44G   48G 48% /none           4.0K     0 4.0K   0% /sys/fs/cgroupnone           5.0M     0 5.0M   0% /run/locknone           3.9G     0 3.9G   0% /run/shmnone           100M     0 100M   0% /run/user

/dev/sda1       236M   40M184M 18% /boot

Please write anawk command to parse the output of “df –h” sothat the following information is displayed: (hint: study“awkc8” in the handout and “example 7” in lab7)

Total Used DiskSpace: 44G

5. Based on theexamples “awkc8” and “awkc88,” write anawk script called “awkc888” that takes two inputvalues and output the larger one as shown below:

$ ./awkc888 10040

100

$

$ ./awkc888 100240

240

$

Answer & Explanation Solved by verified expert
3.9 Ratings (580 Votes)
Sample data filename loginfiletxt ics325sp200221 pts6 75168197229 Wed Apr 29 2209 2327 0117 ics325sp200221 pts10 75168197229 Wed Apr    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students