Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Please answer in Ubuntu and answer all of them--will give upvote for correct answers!! 1. (15 pts) Write a bash script A5p1.sh to output the

Please answer in Ubuntu and answer all of them--will give upvote for correct answers!! image text in transcribed
image text in transcribed
1. (15 pts) Write a bash script A5p1.sh to output the number of executable and non- executable files and subdirectories separately in the directory that is specified as the first command line argument to this script. Do not count recursively in subdirectories. Do not call any external Linux utilities such as ls. You may refer to the test Search.sh example and page 7 of the "Basic Bash Scripting Lab.docx" documentation in Folio to find out how to test if an item in a directory is an executable or non-executable file or subdirectory. When grading, we will test your script using"./A5p1.sh " where can be any absolute (those starting with '/') or relative directory (those not starting with '/'). A sample sun can look like the following (You do NOT need to submit screen shots. Instead submit your source file.): [kwange.computeri-/temp] $./ASpl.sh Number of executable files in : 6 Number of subdirectories in ". A sample sun can look like the following (You do NOT need to submit screen shots. Instead submit your source file.): Ikwange.compull-/temp) S./A5p2.sh 6 6 3 5 8 4 2 1 Length of the sequence: 7 3. (15 pts) Write a bash script A5p3.sh to print out 15 equations on 15 lines, one per line. Each of these equations should be of the form ij-k, where is an integer that runs from 1 through 3, j runs from 1 through 5 and k is the product of 1 and 3. (For example, if i is 2 and is 3, k should be 6.) You will print 15 different equations because the number of possible combinations of i and j is 3*5=15. Your script should use loop to achieve the functionality. Do not define or call any functions in this script. 4. (15 pts) Write a bash script A5p4.sh to print the same 15 equations as in problem 3. This time you need to define a function print Product that takes two integer parameters a and b and prints out an equation of the form abwc, where c is the product of the two parameters a and b. The main part of your script should use loop and call the function printProduct you defined. That is, you should call the function 15 times (with a different pair of arguments being passed each time) to display the 15 equations. 5. (30 pts) Write a bash script A5p5.sh that accepts one command line argument which is supposed to be a positive integer n. The script should print all odd integers from 1 through n. Write a Cor C++ program A5p5.c(pp) to read from stdin as many integers as there are available and then print the squares of all these integers. You should test your code by"./A5p5.sh /A5p5 assuming the compiled C/C++ program is Asps. Submit both files. See the following for a sample run. (You do NOT need to submit screen shots. Instead submit your source file.) [kwange.computer-/temp] Sbash A5p5.sh 10 1 A5p5 1 925 49 81 6. (10 pts) Write a bash script A5p.sh to call your bash script ASp2.sh with all integers from 26 through 35 on the command line. That is, you call A5p2.sh 10 times in your script A5p6.sh using a loop, each time supplying a unique integer between 26 and 35 (inclusive) on the command line for your script A5p2.sh. Make sure your 10 output lists of integers are clearly separated. 1. (15 pts) Write a bash script A5p1.sh to output the number of executable and non- executable files and subdirectories separately in the directory that is specified as the first command line argument to this script. Do not count recursively in subdirectories. Do not call any external Linux utilities such as ls. You may refer to the test Search.sh example and page 7 of the "Basic Bash Scripting Lab.docx" documentation in Folio to find out how to test if an item in a directory is an executable or non-executable file or subdirectory. When grading, we will test your script using"./A5p1.sh " where can be any absolute (those starting with '/') or relative directory (those not starting with '/'). A sample sun can look like the following (You do NOT need to submit screen shots. Instead submit your source file.): [kwange.computeri-/temp] $./ASpl.sh Number of executable files in : 6 Number of subdirectories in ". A sample sun can look like the following (You do NOT need to submit screen shots. Instead submit your source file.): Ikwange.compull-/temp) S./A5p2.sh 6 6 3 5 8 4 2 1 Length of the sequence: 7 3. (15 pts) Write a bash script A5p3.sh to print out 15 equations on 15 lines, one per line. Each of these equations should be of the form ij-k, where is an integer that runs from 1 through 3, j runs from 1 through 5 and k is the product of 1 and 3. (For example, if i is 2 and is 3, k should be 6.) You will print 15 different equations because the number of possible combinations of i and j is 3*5=15. Your script should use loop to achieve the functionality. Do not define or call any functions in this script. 4. (15 pts) Write a bash script A5p4.sh to print the same 15 equations as in problem 3. This time you need to define a function print Product that takes two integer parameters a and b and prints out an equation of the form abwc, where c is the product of the two parameters a and b. The main part of your script should use loop and call the function printProduct you defined. That is, you should call the function 15 times (with a different pair of arguments being passed each time) to display the 15 equations. 5. (30 pts) Write a bash script A5p5.sh that accepts one command line argument which is supposed to be a positive integer n. The script should print all odd integers from 1 through n. Write a Cor C++ program A5p5.c(pp) to read from stdin as many integers as there are available and then print the squares of all these integers. You should test your code by"./A5p5.sh /A5p5 assuming the compiled C/C++ program is Asps. Submit both files. See the following for a sample run. (You do NOT need to submit screen shots. Instead submit your source file.) [kwange.computer-/temp] Sbash A5p5.sh 10 1 A5p5 1 925 49 81 6. (10 pts) Write a bash script A5p.sh to call your bash script ASp2.sh with all integers from 26 through 35 on the command line. That is, you call A5p2.sh 10 times in your script A5p6.sh using a loop, each time supplying a unique integer between 26 and 35 (inclusive) on the command line for your script A5p2.sh. Make sure your 10 output lists of integers are clearly separated<><>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What is conservative approach ?

Answered: 1 week ago

Question

What are the basic financial decisions ?

Answered: 1 week ago