In: Computer Science
I require some assistance with the following assignment as I belive I might be doing it wrong especially in step 2. Your assistance is much appreciated.
Linux Shell Scripting Practice:
Note: The following excercise requires the use of the nano text editor.
Begin by starting a script called “m5a2_part2b” by issuing the following at the command in a open terminal:
$ script m5a2_part2b
Step 1: Using the nano text editor, edit the following “Hello World” program, save as hello.sh, change its permission to executable, and then run the script to check your answer. Do it step-by-step.
In your open terminal type the following:
$ nano hello.sh
Enter the following three lines of code:
#!/bin/bash
clear
echo "Hello, World!"
Now
use CTRL X to exit out of nano.
Type chmod u+x hello.sh to make "hello.sh" executable.
Now type ./hello.sh to run the script. Take a screen shot.
Step 2: Write a “Hello World” program that has the same functionality as seen in Step 1 above, but use hello( ) function to achieve that. Do it again step-by-step.
In your open terminal, type the following:
$ nano vi hello.sh
Now enter the following three lines of code below:
#!/bin/bash
Hello() {
clear
echo "Hello, World!"
}
As before, use CTRL X to exit out of nano.
Type chmod u+x hello.sh to make "hello.sh" executable.
Now type ./hello.sh to run the script. Take a screen shot.
To exit the scipt simply type exit in your open terminal.
$ script m5a2_part2b
Step 1: Using the nano text editor, edit the following “Hello World” program, save as hello.sh, change its permission to executable, and then run the script to check your answer. Do it step-by-step.
In your open terminal type the following:
$ nano hello.sh
Enter the following three lines of code:
#!/bin/bash
clear
echo "Hello, World!"
Now
use CTRL X to exit out of nano.
Type chmod u+x hello.sh to make "hello.sh" executable.
Now type ./hello.sh to run the script. Take a screen shot.
Step 2: Write a “Hello World” program that has the same functionality as seen in Step 1 above, but use hello( ) function to achieve that. Do it again step-by-step.
In your open terminal, type the following:
$ nano vi hello.sh
Now enter the following three lines of code below:
#!/bin/bash
Hello() {
clear
echo "Hello, World!"
}
Hello
As before, use CTRL X to exit out of nano.
Type chmod u+x hello.sh to make "hello.sh" executable.
Now type ./hello.sh to run the script. Take a screen shot.
To exit the scipt simply type exit in your open terminal.
If you have any doubts, leave a comment below before rating. I'll be happy to assist you further.
Do UPVOTE this as I have put a lot of EFFORT in answering this question. It really helps me.