Question

I need help to (let <arithmetic expression>) (expr item1 operator item2) $(( expression )) (${#variable}) Create...

I need help to

(let <arithmetic expression>)
(expr item1 operator item2)
$(( expression ))
(${#variable})

Create a simple script which will take two command line arguments and then multiply them together using each of the methods detailed above.
These are the methods detailed above

Write a Bash script which will print tomorrows date. (Hint: use the command date)

Remember when we looked at variables we discovered $RANDOM will return a random number. This number is between 0 and 32767 which is not always the most useful. Let's write a script which will use this variable and some arithmetic (hint: play with modulus) to return a random number between 0 and 100.
0 0
Add a comment Improve this question Transcribed image text
Answer #1
  • script to take two command-line arguments and then multiply them together.

            a=$1 (retrieving 1st no from command-line)
            b=$2 (retrieving 2nd no from command-line)
            echo "sum = `expr $a \* $b`"

         Output: bash ex.sh 2 3
                      sum = 6

  • script which will print tomorrow's date.

     $ date --date="next day"

  • script to return a random number between 0 and 100.(If we want to limit random number to a certain maximum, we can just compare against the modulus of that maximum + 1 i.e. ). For example, the following will yield results between 0 and 9: echo $(($RANDOM % 101))
Add a comment
Know the answer?
Add Answer to:
I need help to (let <arithmetic expression>) (expr item1 operator item2) $(( expression )) (${#variable}) Create...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please write a BASH Script in LINUX that... 1. is actually executable 2. has a comment...

    Please write a BASH Script in LINUX that... 1. is actually executable 2. has a comment to tell us what you did, why and how. 3. allows a user to enter their name and a number between 1 than 100 (this must be prompted so the user knows what to do) 4. creates a random number between 1 and 100 for you to guess. The command to create a random number is shown below. (if you find a better one...use...

  • Hi, I need help for solving Linux question. . 1.Using the proper text editor, create a...

    Hi, I need help for solving Linux question. . 1.Using the proper text editor, create a shell file called by (your name), your enrollment number, your program and the courses you study. Use the appropriate variables and display the above to the standard output (screen). . 2. Write A Shell Script to perform the following: Display the files and directories Print the date in 24 hour format Display the System id Display the current working directory Print the status of...

  • I need help with a C++ assignment: Write a program containing the following: 1. Variable Definitions...

    I need help with a C++ assignment: Write a program containing the following: 1. Variable Definitions only as (DieRoll, Guess, cnt1, cnt2) followed by this statement: srand((unsigned int)time (NULL)); which will give the random number generator a random starting point. Note: srand and rand require the TIME.H (or iomanip) cnt1 and cnt2 will be used in Chapter 5 drop box as counters for loops. Do NOT create additional variables. Points will be taken off for any additional variable creation. 2....

  • use python Task 1: Machine Epsilon (10 pts) Machine epsilon e is a characteristic of the...

    use python Task 1: Machine Epsilon (10 pts) Machine epsilon e is a characteristic of the CPU in ones computer. This machine constant is used extensively when writing computer code to help make ones algorithms CPU insensitive. Machine epsilon e is the smallest number e such that 1 +e>1 in floating-point arithmetic. For any smaller value of e, round-off error would return 1+e = 1. Machine epsilon is defined by the formula b-where b is the base number used by...

  • I only need help on doing number 4 LON-CAPA COurse ConSSOE-First ear-SprirASSGT9 (1)pd softEdge elackboard Conter...

    I only need help on doing number 4 LON-CAPA COurse ConSSOE-First ear-SprirASSGT9 (1)pd softEdge elackboard Conter 4d Metro Boomin No mpstate/Downloads/ASSGT9%20(1) pdf Users/april/AppData/Local/Pac Your task: Design, code, and debug a MATLAB script that: (1) Asks the user (use a nenu) what kind of function (m-file or anonymous function) will be used. If an m-file, have the user enter the filename; if an anonymous function, have the user enter the function (hint: use MATLAB's eval function in your script to appropriately...

  • Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQ...

    Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQUIRED for this program will use two stacks, an operator stack and a value stack. Both stacks MUST be implemented using a linked list. For this program, you are to write functions for the linked list stacks with the following names: int isEmpty (stack); void push (stack, data); data top (stack); void pop (stack); // return TRUE if the stack has no...

  • Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQ...

    Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQUIRED for this program will use two stacks, an operator stack and a value stack. Both stacks MUST be implemented using a linked list. For this program, you are to write functions for the linked list stacks with the following names: int isEmpty (stack); void push (stack, data); data top (stack); void pop (stack); // return TRUE if the stack has no...

  • Need help with number 3 the last one Need help with number 3 I have already...

    Need help with number 3 the last one Need help with number 3 I have already given the whole question MATH 1030 – Application Assignment 3 Cryptography Due: Thursday, June 4, 2020 at 11:59pm Atlantic time (submit through Brightspace) You must show your work for full marks. The goal of this assignment is to use our knowledge of linear algebra to do cryptography. We will encrypt a plaintext using a cipher where the resulting ciphertext should not be legible unless...

  • PLease, I need help with this Code. PLease create correctly documentations comments for better understanding. This...

    PLease, I need help with this Code. PLease create correctly documentations comments for better understanding. This is the input: JAV001 ARRIVE JAV002 ARRIVE JAV003 ARRIVE JAV004 ARRIVE JAV005 ARRIVE JAV001 DEPART JAV004 DEPART JAV006 ARRIVE JAV007 ARRIVE JAV008 ARRIVE JAV009 ARRIVE JAV010 ARRIVE JAV011 ARRIVE JAV012 ARRIVE JAV013 ARRIVE JAV014 ARRIVE JAV006 DEPART JAV014 DEPART JAV013 DEPART JAV005 DEPART JAV015 ARRIVE JAV010 DEPART JAV002 DEPART JAV015 DEPART JAV014 DEPART JAV009 DEPART JAV003 DEPART JAV008 DEPART JAV007 DEPART JAV012 DEPART JAV011...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT