Bash Scripting
What is Bash?
- BASH - Bourne Again Shell.
- Bash is the most widely used shell in linux system.
- It is used as a default login shell in linux system and macOS.
- It can be also be installed in windows system.
- It is similar to programming languages like python,c,c++,java,etc..
- It has some syntax to follow ,to execute commads.
Advantages of Bash scripting:
- The syntax and commands of bash are similar to the individual command in terminal.
- The syntax are similar to other programming language,which make programmer not to shift completely to other language.
- Quick start.
- Interactive debugging
Disadvantages of Bash scripting:
- Single change in command might make the code harmful.
- Slow execution.
- Not much suitable for large and complex code.
A Simple bash script to print "Hello".
- Create a file with extension ".sh"
- Always first line is "#!bin/bash/"
- Write the code .
- Save by Ctrl+O --> <Enter> --> Ctrl+X (if using nano editor).
- Change the permission by "chmod +x <file_name>"
- Run the script by "./<file_name>"
- The chmod command is used to give permission to file. The +x gives all permission to the file like READ,WRITE,EXECUTE.
No comments:
Post a Comment