Receive all updates via Facebook. Just Click the Like Button Below

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.

1

General Syntax in Linux Shell Scripting

2

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 " \ ".

3

Related posts:

Advertise here

picture picture

Follow us

picture

- Tech-Tutorials twitter.com/techcuriosity

Like us

About Techcuriosity

I am Telson, the webmaster of Techcuriosity.com and through this site, I share my knowledge and curiosities in the Tech World.


What We Offer

  • What is ..?
  • How to ..?
  • Difference between ..?
  • How .. works?
  • Get in Touch

    techcuriosity@gmail.com
    UK : +44 77 33 890 678

    picture picture

    Our Partners

  • Website Design Dubai
  • SEO Link Exchange
  • picture

    picture