Question: Copy the script below and paste into VM . sh text file. Go to the Linux Documents directory. Either create a linux _ lab.sh text
Copy the script below and paste into VM sh text file.
Go to the Linux Documents directory.
Either create a linuxlab.sh text file either in vim or nano OR draganddrop a notepad text file onto the Linux VM
If you dropped and dragged a Windows text file onto the Linux VM you must change the extension on the file to sh and SED out the carriage returns. You run "sed i sr linuxlab.sh in a Terminal CLI. You must also do this if you cut and pasted Windows notepad text into a Linux file.
If you create the script in either vim or nano you do not need to SED the file.
NOTE:nano linuxlab.sh
This will open the nano text editor where you can paste your script. Here's an example script:
#binbash
# This is an example script
echo "Hello, World!"
Save and exit the editor CtrlO to save, CtrlX to exit in nano
Run and study the output the sh script from the command line.
Make the Script Executable
After creating the script, you need to make it executable. You can do this using the chmod command:
chmod x linuxlab.sh
This command gives execute permission to the script file.
Run the Script
Once the script is executable, you can run it using the following command:
linuxlab.sh
The prefix RELATIVE PATH tells the terminal to execute the script from the current directory.
homeUserlinuxlab.sh ABSOLUTE PATH tells the terminal to start from the top of the Linux file system.
You can run the Script with a Specific Interpreter If the script has the #binbash shebang
bash examplescript.sh
Step summary:
Make sure the script has execute permissions chmod x
The script should start with a shebang #binbash to specify the interpreter optional but recommended
If you're running the script in a different directory, use the full path to the script or cd into the directory containing the script first.
Paste a copy of the resulting output in a new text file.
Copy the resulting output including the original command line and paste it in a new text file.
The script includes:
The three execution types:
sequential
recursive iterative looping including a program test loop not only command recursion option
conditional
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
