Tuesday, April 5, 2022

Linux Shell Scripting Introduction

Shell Scripting

In Linux, shells like bash and Korn support programming constructs that are saved as scripts. These scripts become shell commands and hence many Linux commands are scripts.


SHELL environment variable is used to find the current shell


echo $SHELL


Shell Scripting She-bang

The sign #! is called she-bang and is written at top of the script. It passes instruction to program /bin/sh.


To run your script in a certain shell (shell should be supported by your system), start your script with #! followed by the shell name. 

Example

#!/bin/bash  
echo Hello World  
#!/bin/ksh  
echo Hello World  

Comments

Use # symbol to comment a code and the commented code does not get execute.



0 comments:

Post a Comment