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
$