Shell Syntax
SHELL follows a very specific syntax and it's is important to develop good syntax habits as it will help you to debug your code later and save time.
General Syntax in Linux Shell Scripting
Case Sensitivity
As you know Linux is case sensitive, the file names, variables, and arrays used in shell scripts are also case sensitive.
Check out this Example:
#!/bin/bash string1=10 String1=20 echo "The value of string1 is $string1 " echo "The value of String1 is $String1 "
Comments
Comments are used to escape from the code.
This part of the code will be ignored by the program interpreter.
Adding comments, make things easy for the programmer, while editing the code in future.
Example:
#!/bin/bash string1=10 # Assigning value for string1 String1=20 # Assigning value for String2 # Now print the values echo "The value of string1 is $string1 " echo "The value of String1 is $String1 "
Escaping Characters
The escape character we use is the backslash ( \ ).
This is used to escape any type of character that might interfere with our code.
For example using the dollor sign.
#!/bin/bash echo "The value of \$1 USD is \$1 CAD "
Try the same example without " \ ".
Related posts:
- Shell Scripting Introduction
- Shell Syntax
- Shell - Strings
- Shell - Variables
- Shell - User Intraction
- First Shell Script
- Shell - Arithmetics
- Shell - Case Statement
- Shell - Command Line Arguments
- Shell - For Loop
- Shell - While Loops
- Shell - IF Statements
- Shell - Input Output Redirections
- Shell - Pipes and Filters
- Shell - Process Management
Your IP address1 is: 172.18.0.2
Tutorials
Latest Updates
Follow us
- Tech-Tutorials twitter.com/techcuriosity