Shell Scripting- USING variableS

How to create Variables in Shell Scripts

To set a variable in the shell, use the syntax:-


Note – Variables are case-sensitive so, after they are defined, they must later be spelled using exactly the same uppercase and lowercase letters. Variable names have a limit of 255 characters.

Do not place spaces around the = sign. If the value contains spaces or special characters, use single or double quotes; for example:

$ var=”variable with spaces”

Display Variable value

To display the value of a shell variable, use the echo command and place a $ immediately in front of the variable name. You can also display more than one variable in the same line using single echo command. For Example :

$ var1=18

$ var2=” Till I Die”

$ echo $var1 $var2

18 Till I Die

Special Shell Variables

Several shell variables are available to users. The shell sets the variable value at a process creation or termination.

Shell CommanDS ->>>click Here

Leave a Comment