################################################# # IS380 Shell Scripting Final # Date: 7/30/2021 # # Total 100 points, 20% of your grade # # Name: -- your name here -- # # Note: Before or by 8PM, you...

please so attached files, final_exam.txt is the questions i need


################################################# # IS380 Shell Scripting Final # Date: 7/30/2021 # # Total 100 points, 20% of your grade # # Name: -- your name here -- # # Note: Before or by 8PM, you need to submit the following files: # 1, final1.sh # 2, final2.txt # 3, final3.txt # 4, final4.txt # 5, final5.sh # 6, final6.txt (extra credit) ################################################# 1, (Total 20 points) Please review the shell script final1.sh, comment out the lines that has syntax or logic errors, explain what's wrong with the code in comment lines and fix the problems. There are 4 errors and each correction worth 5 points. You should run your code to see if it addresses all problems. If not 100% error-free or 100% functioning as expected, write a few lines of comments at the end of the file to explain what they are for partial credit. Then you need to submit your final1.sh If the script is corrected 100%, you will see the following behaviors: % ./final1.sh Please enter a positive integer: 5 ============================================================== User entered: 5 Printing 5 line(s) 1 22 333 4444 55555 % ./final1.sh Please enter a positive integer: 55 Only integer between 1 and 25 is allowed 2, (total 20 points) After you run a BASH shell script, an exit code was generated by the shell. Please answer the following questions: Q2.1, (5 points) How do you get and report the exit code? Q2.2, (15 points) Explain what do these exit codes mean: 0, 1, 2 Please create and submit a text file final2.txt with your answers in it. 3, (25 points) I went to my CoCalc server /opt directory and executed a command: % ls -R > somefiles.txt Please review the somefiles.txt file and then you will type a line of shell command to get google directory structure as the following: % cmd1 | cmd2 | cmd3 ./google: ./google/chrome: ./google/chrome/MEIPreload: ./google/chrome/WidevineCdm: ./google/chrome/WidevineCdm/_platform_specific: ./google/chrome/WidevineCdm/_platform_specific/linux_x64: ./google/chrome/cron: ./google/chrome/default_apps: ./google/chrome/locales: ./google/chrome/swiftshader: (Hint: I used cat, grep and sed for these cmds. You can use any numbers of commands to make it work.) Q3.1, (15 points, 5 points for each cmd) You need to create a final3.txt with the exact commands you used for: cmd1 cmd2 cmd3 IF you didn't use 3 commands, just list what you used. Q3.2, (10 points) If you successfully did Q3.1 completely, then please do % cmd1 | cmd2 | cmd3 > google.txt If you weren't able to complete Q3.1, simply created a file google.txt with the following content: ./google: ./google/chrome: ./google/chrome/MEIPreload: ./google/chrome/WidevineCdm: ./google/chrome/WidevineCdm/_platform_specific: ./google/chrome/WidevineCdm/_platform_specific/linux_x64: ./google/chrome/cron: ./google/chrome/default_apps: ./google/chrome/locales: ./google/chrome/swiftshader: Now, here is the question: write a cmd4 to get rid of the '.' in the beginning and ':' in the end of each line. The result should look lihe the following: % cmd4 /google /google/chrome /google/chrome/MEIPreload /google/chrome/WidevineCdm /google/chrome/WidevineCdm/_platform_specific /google/chrome/WidevineCdm/_platform_specific/linux_x64 /google/chrome/cron /google/chrome/default_apps /google/chrome/locales /google/chrome/swiftshader Add the cmd4 in the final3.txt and submit it. (Hint: You may use any numbers of shell commands as long as it works. I use two sed piping together.) 4, (15 points, 5 points for each short answer) Create a file final4.txt and answer the following questions: Q4.1: (10 points) There are control flags in regular expression. What do flag g and flag i mean? Q4.2, (5 points) How do you create a BASH variable weekdays and assign to it a BASH array that contains all the weekday: Monday, Tuesday, etc. It has to be legal BASH syntax. 5, (20 points) Edit final5.sh to make it a simple BASH shell script that only do integer addition and subtraction with the following behavior: % ./final5.sh George 100 + 20 Hello George! Today is 07/24/2021. 100 + 20 = 120 % ./final5_answer.sh Andy 100 - 20 Hello Andy! Today is 07/24/2021. 100 - 20 = 80 Please note, the script takes 4 user arguments (name, num1, + or -, num2). 6, Extra credits (10 points): Read the file scores.txt and try to figire out its pattern. Please create a file final6.txt and answer the following questions, 5 points each. The objective is to test your basic understantding of awk. If you can create solutions using other means, it's also good. Q6.1, On your terminal, you execute cmd1 to find out Math scores and sort it by name. % cmd1 Andy Math 92 Danny Math 85 George Math 65 Mary Math 82 Mike Math 74 Nancy Math 78 Sandy Math 69 What is cmd1? (Hint: I used awk and sort) Q6.2, On your terminal, you execute cmd2 to find out high score records. % cmd2 Andy Math 92 Sandy Python 91 Sandy C++ 91 What is cmd2? (Hint: I used awk) Please write your answer and submit your final6.txt. #!/bin/bash #======================================= # final5.sh # Total: 20 points # # final5.sh is a simple custom integer calculator # Usage: # % ./final5.sh name num1 op num2 # # - num1 and num2: integers # - op: +, -, *, /, % #======================================= echo date echo "Hello name" #!/bin/bash #======================================= # final1.sh # Total: 20 points # # There are 4 errors. # Each error corrected get you 5 points. # #======================================= echo -n "Please enter a positive integer: " read maxLineCount if (( maxLineCount >= 1 && maxLineCount <= 25)); then echo echo "==============================================================" echo 'user entered: $maxlinecount' echo "printing $maxlinecount line(s)" echo numbercount=1 currentline=1 while [ numbercount -le maxlinecount ] do newcount=1 num=$(( numbercount % 10 )) while [ $newcount -le $numbercount ] do echo -n num (( newcount++ )) done echo ((numbercount++)) done echo else echo "only integer between 1 and 25 is allowed" done 1 george math 65 2 mary math 82 3 mike math 74 4 nancy math 78 5 sandy math 69 6 danny math 85 7 andy math 92 8 andy english 82 9 bob english 76 10 george english 82 11 ken english 87 12 mary english 78 13 george physics 73 14 andy python 73 15 george python 52 16 mary python 76 17 ken python 82 18 bob python 46 19 sandy python 91 20 danny python 82 21 andy c++ 73 22 george c++ 52 23 mary c++ 76 24 ken c++ 82 25 bob c++ 46 26 sandy c++ 91 27 danny c++ 82 28 andy circuit 83 29 george circuit 77 30 mary circuit 78 31 ken circuit 86 32 bob circuit 58 33 sandy circuit 71 34 danny circuit 69 .: slic3r cabal ghc google intel nteract ./slic3r: build.pl license readme.md appveyor.yml lib local-lib package share slic3r.pl src t translation utils var xs ./slic3r/lib: slic3r slic3r.pm ./slic3r/lib/slic3r: config.pm expolygon.pm extrusionloop.pm extrusionpath.pm flow.pm gcode gui gui.pm geometry geometry.pm layer.pm line.pm model.pm point.pm polygon.pm polyline.pm print print.pm svg.pm surface.pm test test.pm ./slic3r/lib/slic3r/gcode: arcfitting.pm motionplanner.pm pressureregulator.pm reader.pm vibrationlimit.pm ./slic3r/lib/slic3r/gui: 2dbed.pm 3dscene.pm aboutdialog.pm bedshapedialog.pm bonjourbrowser.pm colorscheme.pm configwizard.pm controller controller.pm mainframe.pm notifier.pm optionsgroup optionsgroup.pm plater plater.pm preferences.pm preset.pm preseteditor.pm preseteditordialog.pm progressstatusbar.pm projector.pm reloaddialog.pm slaprintoptions.pm ./slic3r/lib/slic3r/gui/controller: manualcontroldialog.pm printerpanel.pm ./slic3r/lib/slic3r/gui/optionsgroup: field.pm ./slic3r/lib/slic3r/gui/plater: 2d.pm 2dtoolpaths.pm 3d.pm 3dpreview.pm lambdaobjectdialog.pm objectcutdialog.pm objectpartspanel.pm objectrotatefacedialog.pm objectsettingsdialog.pm overridesettingspanel.pm splinecontrol.pm ./slic3r/lib/slic3r/geometry: clipper.pm ./slic3r/lib/slic3r/print: gcode.pm object.pm simple.pm state.pm supportmaterial.pm ./slic3r/lib/slic3r/test: sectioncut.pm ./slic3r/local-lib: bin lib man ./slic3r/local-lib/bin: enc2xs encguess instmodsh piconv use-devel-checklib xspp xsubpp ./slic3r/local-lib/lib: perl5 ./slic3r/local-lib/lib/perl5: 5.30.0 devel extutils getopt io method mock module moo moo.pm spiffy spiffy.pm spiffy.pod test test2 test2.pm text newgetopt.pl ok.pm oo.pm x86_64-linux-gnu-thread-multi ./slic3r/local-lib/lib/perl5/5.30.0: x86_64-linux-gnu-thread-multi ./slic3r/local-lib/lib/perl5/5.30.0/x86_64-linux-gnu-thread-multi: ./slic3r/local-lib/lib/perl5/devel: checklib.pm ./slic3r/local-lib/lib/perl5/extutils: command command.pm liblist liblist.pm mm.pm mm_aix.pm mm_any.pm mm_beos.pm mm_cygwin.pm mm_dos.pm mm_darwin.pm mm_macos.pm mm_nw5.pm mm_os2.pm mm_qnx.pm mm_uwin.pm mm_unix.pm mm_vms.pm mm_vos.pm mm_win32.pm mm_win95.pm my.pm makemaker makemaker.pm mkbootstrap.pm mksymlists.pm parsexs parsexs.pm parsexs.pod typemap typemaps typemaps.pm xspp xspp.pm xspp.pod testlib.pm xsubpp ./slic3r/local-lib/lib/perl5/extutils/command: mm.pm ./slic3r/local-lib/lib/perl5/extutils/liblist: kid.pm ./slic3r/local-lib/lib/perl5/extutils/makemaker: config.pm faq.pod locale.pm tutorial.pod version version.pm ./slic3r/local-lib/lib/perl5/extutils/makemaker/version: regex.pm vpp.pm ./slic3r/local-lib/lib/perl5/extutils/parsexs: constants.pm countlines.pm eval.pm utilities.pm ./slic3r/local-lib/lib/perl5/extutils/typemap: basic.pm default.pm objectmap.pm stl stl.pm ./slic3r/local-lib/lib/perl5/extutils/typemap/stl: string.pm vector.pm ./slic3r/local-lib/lib/perl5/extutils/typemaps: basic.pm cmd.pm default.pm inputmap.pm objectmap.pm outputmap.pm stl stl.pm type.pm ./slic3r/local-lib/lib/perl5/extutils/typemaps/stl: list.pm string.pm vector.pm ./slic3r/local-lib/lib/perl5/extutils/xspp: cmd.pm driver.pm exception exception.pm grammar.pm lexer.pm node node.pm parser.pm plugin plugin.pod typemap typemap.pm ./slic3r/local-lib/lib/perl5/extutils/xspp/exception: code.pm object.pm perlcode.pm simple.pm stdmessage.pm unknown.pm ./slic3r/local-lib/lib/perl5/extutils/xspp/node: access.pm argument.pm class.pm comment.pm constructor.pm destructor.pm enum.pm enumvalue.pm file.pm function.pm member.pm method.pm module.pm package.pm percany.pm preprocessor.pm raw.pm type.pm ./slic3r/local-lib/lib/perl5/extutils/xspp/plugin: feature ./slic3r/local-lib/lib/perl5/extutils/xspp/plugin/feature: default_xs_typemap.pm ./slic3r/local-lib/lib/perl5/extutils/xspp/typemap: parsed.pm reference.pm simple.pm wrapper.pm ./slic3r/local-lib/lib/perl5/getopt: long.pm ./slic3r/local-lib/lib/perl5/io: atomicfile.pm innerfile.pm lines.pm scalar.pm scalararray.pm stringy.pm wrap.pm wraptie.pm ./slic3r/local-lib/lib/perl5/method: generate ./slic3r/local-lib/lib/perl5/method/generate: accessor.pm buildall.pm constructor.pm demolishall.pm ./slic3r/local-lib/lib/perl5/mock: config.pm ./slic3r/local-lib/lib/perl5/module: build ./slic3r/local-lib/lib/perl5/module/build: withxspp.pm ./slic3r/local-lib/lib/perl5/moo: handlemoose handlemoose.pm object.pm role.pm _utils.pm _mro.pm _strictures.pm sification.pm ./slic3r/local-lib/lib/perl5/moo/handlemoose: fakemetaclass.pm _typemap.pm ./slic3r/local-lib/lib/perl5/spiffy: mixin.pm ./slic3r/local-lib/lib/perl5/test: base base.pm base.pod builder builder.pm differences.pm more.pm simple.pm tester tester.pm tutorial.pod use ./slic3r/local-lib/lib/perl5/test/base: filter.pm filter.pod ./slic3r/local-lib/lib/perl5/test/builder: formatter.pm io module.pm tester 25));="" then="" echo="" echo="" "="============================================================="" echo="" 'user="" entered:="" $maxlinecount'="" echo="" "printing="" $maxlinecount="" line(s)"="" echo="" numbercount="1" currentline="1" while="" [="" numbercount="" -le="" maxlinecount="" ]="" do="" newcount="1" num="$((" numbercount="" %="" 10="" ))="" while="" [="" $newcount="" -le="" $numbercount="" ]="" do="" echo="" -n="" num="" ((="" newcount++="" ))="" done="" echo="" ((numbercount++))="" done="" echo="" else="" echo="" "only="" integer="" between="" 1="" and="" 25="" is="" allowed"="" done="" 1="" george="" math="" 65="" 2="" mary="" math="" 82="" 3="" mike="" math="" 74="" 4="" nancy="" math="" 78="" 5="" sandy="" math="" 69="" 6="" danny="" math="" 85="" 7="" andy="" math="" 92="" 8="" andy="" english="" 82="" 9="" bob="" english="" 76="" 10="" george="" english="" 82="" 11="" ken="" english="" 87="" 12="" mary="" english="" 78="" 13="" george="" physics="" 73="" 14="" andy="" python="" 73="" 15="" george="" python="" 52="" 16="" mary="" python="" 76="" 17="" ken="" python="" 82="" 18="" bob="" python="" 46="" 19="" sandy="" python="" 91="" 20="" danny="" python="" 82="" 21="" andy="" c++="" 73="" 22="" george="" c++="" 52="" 23="" mary="" c++="" 76="" 24="" ken="" c++="" 82="" 25="" bob="" c++="" 46="" 26="" sandy="" c++="" 91="" 27="" danny="" c++="" 82="" 28="" andy="" circuit="" 83="" 29="" george="" circuit="" 77="" 30="" mary="" circuit="" 78="" 31="" ken="" circuit="" 86="" 32="" bob="" circuit="" 58="" 33="" sandy="" circuit="" 71="" 34="" danny="" circuit="" 69="" .:="" slic3r="" cabal="" ghc="" google="" intel="" nteract="" ./slic3r:="" build.pl="" license="" readme.md="" appveyor.yml="" lib="" local-lib="" package="" share="" slic3r.pl="" src="" t="" translation="" utils="" var="" xs="" ./slic3r/lib:="" slic3r="" slic3r.pm="" ./slic3r/lib/slic3r:="" config.pm="" expolygon.pm="" extrusionloop.pm="" extrusionpath.pm="" flow.pm="" gcode="" gui="" gui.pm="" geometry="" geometry.pm="" layer.pm="" line.pm="" model.pm="" point.pm="" polygon.pm="" polyline.pm="" print="" print.pm="" svg.pm="" surface.pm="" test="" test.pm="" ./slic3r/lib/slic3r/gcode:="" arcfitting.pm="" motionplanner.pm="" pressureregulator.pm="" reader.pm="" vibrationlimit.pm="" ./slic3r/lib/slic3r/gui:="" 2dbed.pm="" 3dscene.pm="" aboutdialog.pm="" bedshapedialog.pm="" bonjourbrowser.pm="" colorscheme.pm="" configwizard.pm="" controller="" controller.pm="" mainframe.pm="" notifier.pm="" optionsgroup="" optionsgroup.pm="" plater="" plater.pm="" preferences.pm="" preset.pm="" preseteditor.pm="" preseteditordialog.pm="" progressstatusbar.pm="" projector.pm="" reloaddialog.pm="" slaprintoptions.pm="" ./slic3r/lib/slic3r/gui/controller:="" manualcontroldialog.pm="" printerpanel.pm="" ./slic3r/lib/slic3r/gui/optionsgroup:="" field.pm="" ./slic3r/lib/slic3r/gui/plater:="" 2d.pm="" 2dtoolpaths.pm="" 3d.pm="" 3dpreview.pm="" lambdaobjectdialog.pm="" objectcutdialog.pm="" objectpartspanel.pm="" objectrotatefacedialog.pm="" objectsettingsdialog.pm="" overridesettingspanel.pm="" splinecontrol.pm="" ./slic3r/lib/slic3r/geometry:="" clipper.pm="" ./slic3r/lib/slic3r/print:="" gcode.pm="" object.pm="" simple.pm="" state.pm="" supportmaterial.pm="" ./slic3r/lib/slic3r/test:="" sectioncut.pm="" ./slic3r/local-lib:="" bin="" lib="" man="" ./slic3r/local-lib/bin:="" enc2xs="" encguess="" instmodsh="" piconv="" use-devel-checklib="" xspp="" xsubpp="" ./slic3r/local-lib/lib:="" perl5="" ./slic3r/local-lib/lib/perl5:="" 5.30.0="" devel="" extutils="" getopt="" io="" method="" mock="" module="" moo="" moo.pm="" spiffy="" spiffy.pm="" spiffy.pod="" test="" test2="" test2.pm="" text="" newgetopt.pl="" ok.pm="" oo.pm="" x86_64-linux-gnu-thread-multi="" ./slic3r/local-lib/lib/perl5/5.30.0:="" x86_64-linux-gnu-thread-multi="" ./slic3r/local-lib/lib/perl5/5.30.0/x86_64-linux-gnu-thread-multi:="" ./slic3r/local-lib/lib/perl5/devel:="" checklib.pm="" ./slic3r/local-lib/lib/perl5/extutils:="" command="" command.pm="" liblist="" liblist.pm="" mm.pm="" mm_aix.pm="" mm_any.pm="" mm_beos.pm="" mm_cygwin.pm="" mm_dos.pm="" mm_darwin.pm="" mm_macos.pm="" mm_nw5.pm="" mm_os2.pm="" mm_qnx.pm="" mm_uwin.pm="" mm_unix.pm="" mm_vms.pm="" mm_vos.pm="" mm_win32.pm="" mm_win95.pm="" my.pm="" makemaker="" makemaker.pm="" mkbootstrap.pm="" mksymlists.pm="" parsexs="" parsexs.pm="" parsexs.pod="" typemap="" typemaps="" typemaps.pm="" xspp="" xspp.pm="" xspp.pod="" testlib.pm="" xsubpp="" ./slic3r/local-lib/lib/perl5/extutils/command:="" mm.pm="" ./slic3r/local-lib/lib/perl5/extutils/liblist:="" kid.pm="" ./slic3r/local-lib/lib/perl5/extutils/makemaker:="" config.pm="" faq.pod="" locale.pm="" tutorial.pod="" version="" version.pm="" ./slic3r/local-lib/lib/perl5/extutils/makemaker/version:="" regex.pm="" vpp.pm="" ./slic3r/local-lib/lib/perl5/extutils/parsexs:="" constants.pm="" countlines.pm="" eval.pm="" utilities.pm="" ./slic3r/local-lib/lib/perl5/extutils/typemap:="" basic.pm="" default.pm="" objectmap.pm="" stl="" stl.pm="" ./slic3r/local-lib/lib/perl5/extutils/typemap/stl:="" string.pm="" vector.pm="" ./slic3r/local-lib/lib/perl5/extutils/typemaps:="" basic.pm="" cmd.pm="" default.pm="" inputmap.pm="" objectmap.pm="" outputmap.pm="" stl="" stl.pm="" type.pm="" ./slic3r/local-lib/lib/perl5/extutils/typemaps/stl:="" list.pm="" string.pm="" vector.pm="" ./slic3r/local-lib/lib/perl5/extutils/xspp:="" cmd.pm="" driver.pm="" exception="" exception.pm="" grammar.pm="" lexer.pm="" node="" node.pm="" parser.pm="" plugin="" plugin.pod="" typemap="" typemap.pm="" ./slic3r/local-lib/lib/perl5/extutils/xspp/exception:="" code.pm="" object.pm="" perlcode.pm="" simple.pm="" stdmessage.pm="" unknown.pm="" ./slic3r/local-lib/lib/perl5/extutils/xspp/node:="" access.pm="" argument.pm="" class.pm="" comment.pm="" constructor.pm="" destructor.pm="" enum.pm="" enumvalue.pm="" file.pm="" function.pm="" member.pm="" method.pm="" module.pm="" package.pm="" percany.pm="" preprocessor.pm="" raw.pm="" type.pm="" ./slic3r/local-lib/lib/perl5/extutils/xspp/plugin:="" feature="" ./slic3r/local-lib/lib/perl5/extutils/xspp/plugin/feature:="" default_xs_typemap.pm="" ./slic3r/local-lib/lib/perl5/extutils/xspp/typemap:="" parsed.pm="" reference.pm="" simple.pm="" wrapper.pm="" ./slic3r/local-lib/lib/perl5/getopt:="" long.pm="" ./slic3r/local-lib/lib/perl5/io:="" atomicfile.pm="" innerfile.pm="" lines.pm="" scalar.pm="" scalararray.pm="" stringy.pm="" wrap.pm="" wraptie.pm="" ./slic3r/local-lib/lib/perl5/method:="" generate="" ./slic3r/local-lib/lib/perl5/method/generate:="" accessor.pm="" buildall.pm="" constructor.pm="" demolishall.pm="" ./slic3r/local-lib/lib/perl5/mock:="" config.pm="" ./slic3r/local-lib/lib/perl5/module:="" build="" ./slic3r/local-lib/lib/perl5/module/build:="" withxspp.pm="" ./slic3r/local-lib/lib/perl5/moo:="" handlemoose="" handlemoose.pm="" object.pm="" role.pm="" _utils.pm="" _mro.pm="" _strictures.pm="" sification.pm="" ./slic3r/local-lib/lib/perl5/moo/handlemoose:="" fakemetaclass.pm="" _typemap.pm="" ./slic3r/local-lib/lib/perl5/spiffy:="" mixin.pm="" ./slic3r/local-lib/lib/perl5/test:="" base="" base.pm="" base.pod="" builder="" builder.pm="" differences.pm="" more.pm="" simple.pm="" tester="" tester.pm="" tutorial.pod="" use="" ./slic3r/local-lib/lib/perl5/test/base:="" filter.pm="" filter.pod="" ./slic3r/local-lib/lib/perl5/test/builder:="" formatter.pm="" io="" module.pm="">
Jul 31, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here