Question: NOTE: The first line of your script should be the following: #!/bin/bash This must be exactly the first line of your script. For ODP404, you
NOTE: The first line of your script should be the following:
#!/bin/bash
This must be exactly the first line of your script.
For ODP404, you need to write a script that accepts 2 command line arguments (in these examples, I'm assuming your script is named "script"):
script word number
should print the given word, once per line, a total of "number" times:
The following command: script Hello 5
would produce 5 lines of output: Hello Hello Hello Hello Hello
You may assume both the word and the number will be present (don't worry about the case where the user forgets one or both of these). If numbers is less than 1, your script shouldn't print anything.
After you write your script and test it, assess it using the assess command.
For-Loops
To do this, you can use a bash for loop. The syntax is similar to C:
for ((i=0;i<10;i++)) do things to do possibly more things to do and so on done
The above code will repeat the statement between "do" and "done" and will increment the value of the variable i after each iteration.
Play around with this to make sure you understand for loops; refer to your CSE 121 notes or other resources (including me!) if you're unsure how a for loop works.
Try things like this too:
for ((i=5;i>0;i--)) do echo i=$i done
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
