Recent Posts
- jQuery attrAugust 12, 2021
- jQuery mouseenterAugust 9, 2021
- jQuery ToggleclassAugust 6, 2021
- jQuery attr
Bash Shell in Linux
Bash Stands for “Bourne Again Shell” in the shell ecosystem. It is a free version of Bourne shell distribution associated with the Linux and GNU operating systems. It is similar to the command-line shell with extra features incorporated in it and bash is a specified part of IEEE POSIX. Bash Shell is widely available for various operating systems and a default command-line interpreter for almost all GNU/Linux systems. Bash also includes the features of Cshell and Kshell.
Understanding of Bash Shell in Linux
Let’s see the concept of bash shell in Linux as given below:
Syntax of Bash Shell in Linux
Let see the syntax of the bash shell in Linux along with a list of options that can be used.
bash -option filename
List of Option :
Let us discuss each option in details :
Now we will understand the concept of Shell Scripting in detail.
What is Shell Scripting?
A shell script is segregation of the list of commands in order to optimize any task and cost-effective, similar to other programming languages with well-defined standards. When you have any experience then it will be beneficial to understand quickly, however, we will make you understand the concept and implementation of shell scripting.
A shell script comprises the following elements:
Reason for Developing Shell Script
The steps involved in creating a Shell Script:
We need to create a new file with a vi editor.FileName of script file with extension .sh.
Sample creation of a small script,
Code:
#!/bin/bash
ls
Command ‘ls’ will be executed when we execute the script test.sh, file and display the output.
Output:
What is Shell Comments?
Adding any Comment in any program plays a vital role. It means shell script will ignore that command or line.
Example:
#This is my first script
Shell Variables
Variables are those to store data in terms of characters and numbers. Similarly, shell variables are used to store information at run time provided by any user and they can be used by the shell to evaluate the variable.
For example, below we have created a shell variable and then printed it:
Code:
variable =”Hey”
echo $variable
Below is a small script which will use a variable:
#!/bin/bash # Bash Shell
a=”fine”
b=”Good”
echo “My first Shell Script?”
echo “How do you do $a?”
read data1 ## Reading the variable
echo “I am $b too!”
Advantages and Disadvantages of Bash Shell
Let’s see the advantages and disadvantages of the bash shell:
Advantages
The syntax and command are approx the same as those directly entered in command line so developer or programmer does not face much problem in implementation. Let see the advantages of the bash shell as given below.
Disadvantages
MCP is the right place for best computer Courses institute and advance Courses in Mohali and Chandigarh.The Complete Programming Academy can change your life – providing you with the knowledge, skills, and performance in a second language which helps you to excel in your job.You can also Contact us for 6 month industrial training institute in Mohali.