Hello Everyone, Today we will study about basics of Bash Scripting.
Bash Scripting is a simple text file which contains series of commands.The scripting files ends with the .sh extension . it must be given execute permission before using it.there are the combination of different commands that we use in the terminal like (mkdir , cp , ls ).this is a UNIX command language which was written by brian fox.this was first introduced in year 1989.Since the bash commands are also available in window also but its more popular in Linux systems.It is also called as Bourne-Again Shell, Bash is an sh-compatible command language interpreter that executes.
Commands read from the standard input or from a file. Bash also incorporates useful features from the Korn and C shells (ksh and cash). these are basically used for easy management of different day to day task executions. a user can create any shortcuts to run any process or can easily handle any service in their respective manner .lets under stand how to create a simple scripts in linux. Now here we will learn to create a simple script that is used to display time in the terminal. Lets check it down below how here we can use any text editor like here i will be using nano editor
Open Terminal in ubuntu by pressing ctlr+alt+t and then
for displaying the date on the terminal we must know the path of the terminal window which can be checked
by typing tty in the root mode and here we get /dev/pts/7
Here type nano (scriptname).sh i have used date.sh . the extension must be .sh otherwise it wont be accessible and then adding the commands
after entering the commands lets close it by pressing ctrl+O and enter and after that ctrl+x to exit
than we have to give the execute permission to the file by entering
now executing by using ./(script name) in our case its ./date.sh and lets see the result
and the result is