Pranaam to all bhai ji _/\_
Today we are going to discuss about shell scripting
most of us is familiar with word "shell scripting/bash scripting". This is nothing but just linux commands written in a file and when we execute that file via Linux terminal, commands execution starts one by one .
Usage of shell script:-
---> shell script is basically used for automation of tasks or if you need to run commands again and again
Basic shell script:-
so lets start with shell scripting......
Linux shell terminal is the user interface through which user run commands and shell terminal forward those commands to kernel for processing , after processing kernel return result to shell terminal and we can see the output of command on shell terminal
for example , write this on your shell terminal
echo "pranaam bhai ji _/\_"
and press enter
it will print message pranaam bhai ji _/\_ on screen
we can do this using shell script too , how ........ lets start ^_^
we will use vi file editor for file writing/editing
here is link for basic usage of vi file editor http://www.mannulinux.org/2013/08/vi-file-editor-in-linux.html
for a shell script , we just need to specify list of commands that we want to run via terminal
create a file with .sh extension , like ica.sh :p
i want to print "pranaam bhai ji _/\_" on terminal using shell script. as mentioned earlier , we need to write command in file
i used echo "pranaam bhai ji _/\_" when i was using terminal so write the same command in ica.sh file
save this file and run
for running .sh file, we have 2 ways
one is to use command
sh shell_script.sh
here sh is the shell terminal binary (/bin/sh) you can also use command
bash shell_script.sh
bash is also a shell terminal binary (/bin/bash)
second is
make shell script file executable by using chmod command
and then ./shell_script.sh
here ./ means current directory, But only . (dot) means execute given command file in current shell without starting the new copy of shell.
so here goes our very first tutorial on shell scripting . we will study more about shell script in our next tutorial
Thank you
Greetz to :- Guru ji Zero , code breaker ica, Aasim shaikh,Reborn, Raman kumar rana,INX_r0ot,Darkwolf indishell, Chinmay Pandya ,Silent poison India,Magnum sniper,Atul Dwivedi,ethicalnoob Indishell,Local root indishell,Irfninja indishell,Hardeep bhai,Mannu,Viki and AR AR bhai ji <3
Today we are going to discuss about shell scripting
most of us is familiar with word "shell scripting/bash scripting". This is nothing but just linux commands written in a file and when we execute that file via Linux terminal, commands execution starts one by one .
Usage of shell script:-
---> shell script is basically used for automation of tasks or if you need to run commands again and again
Basic shell script:-
so lets start with shell scripting......
Linux shell terminal is the user interface through which user run commands and shell terminal forward those commands to kernel for processing , after processing kernel return result to shell terminal and we can see the output of command on shell terminal
for example , write this on your shell terminal
echo "pranaam bhai ji _/\_"
and press enter
it will print message pranaam bhai ji _/\_ on screen
we can do this using shell script too , how ........ lets start ^_^
we will use vi file editor for file writing/editing
here is link for basic usage of vi file editor http://www.mannulinux.org/2013/08/vi-file-editor-in-linux.html
for a shell script , we just need to specify list of commands that we want to run via terminal
create a file with .sh extension , like ica.sh :p
i want to print "pranaam bhai ji _/\_" on terminal using shell script. as mentioned earlier , we need to write command in file
i used echo "pranaam bhai ji _/\_" when i was using terminal so write the same command in ica.sh file
save this file and run
for running .sh file, we have 2 ways
one is to use command
sh shell_script.sh
here sh is the shell terminal binary (/bin/sh) you can also use command
bash shell_script.sh
bash is also a shell terminal binary (/bin/bash)
second is
make shell script file executable by using chmod command
and then ./shell_script.sh
here ./ means current directory, But only . (dot) means execute given command file in current shell without starting the new copy of shell.
so here goes our very first tutorial on shell scripting . we will study more about shell script in our next tutorial
Thank you
Greetz to :- Guru ji Zero , code breaker ica, Aasim shaikh,Reborn, Raman kumar rana,INX_r0ot,Darkwolf indishell, Chinmay Pandya ,Silent poison India,Magnum sniper,Atul Dwivedi,ethicalnoob Indishell,Local root indishell,Irfninja indishell,Hardeep bhai,Mannu,Viki and AR AR bhai ji <3
As per what you mentioned, is it mandatory to have a shell script an extension .sh ? Without the extension is it not going to be a shell script? As far as I have learnt over years, Linux/Unix do not depend on file extension but rather file header!
ReplyDeletewell it was just for beginners :)
ReplyDeleteand yes its true, we dont need .sh extension for shell script file
we may have any extension for shell script file or even if we dont have any extension , we can run it
whatever i mentioned , it was just for beginners not to get confuse :)
@UnhappyGhost, dude, it is always recommended for providing extension for regex's. if you have thousand files, and you were looking for all shell scripts to move to another location, it will be very easy by finding them with extensions. :]
ReplyDeletebhai ji ne to ek dum "hell yesh" answer de diya :')
ReplyDelete