Shell Scripting Class 1 getting started shell scripting
Shell Scripting Class 1 article will explain to you about shell scripting write and its usage.
What is shell scripting..? shell scripting class 1
Normally shells are interactive. It means shell accept command from you (via keyboard) and execute them. But if you use command one by one (sequence of ‘n’ number of commands) , the you can store this sequence of command to text file and tell the shell to execute this text file instead of entering the commands. This is know as shell script.
Shell script defined as:
“Shell Script is series of command written in plain text file. Shell script is just like batch file is MS-DOS but have more power than the MS-DOS batch file.”
How to use Shell
To use shell (You start to use your shell as soon as you log into your system) you have to simply type commands.
How to write shell script
Following steps are required to write shell script:
- Use any editor like vi or nano to write shell script.
- After writing shell script set execute permission for your script as follows
chmod permission your-script-name
$ chmod +x your-script-name $ chmod 755 your-script-name
Note: This will set read write execute(7) permission for owner, for group and other permission is read and execute only(5).
(3) Execute your script as
bash your-script-name sh your-script-name ./your-script-name
$ bash bar $ sh bar $ ./bar
NOTE: In the last syntax ./ means current directory, But only . (dot) means execute given command file in current shell without starting the new copy of shell, The syntax for . (dot) command is as follows
Syntax: . command-name
$ . foo
Now you are ready to write first shell script that will print “Knowledge is Power” on screen.
your feedback is valuable to us … shell scripting class 1