Shell Scripting Class 1 getting started shell scripting

Shell Scripting Class 1 article will explain to you about shell scripting write and its usage.

https://www.youtube.com/watch?v=VSXOzU3Wi8o

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:

  1. Use any editor like vi or nano to write shell script.
  2. After writing shell script set execute permission for your script as follows

syntax:

chmod permission your-script-name

Examples:

 $ 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

syntax:

 bash your-script-name
 sh your-script-name
 ./your-script-name

Examples:

$ 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

Example:

$ . 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

Related Articles

What is bash scripting

cut command 8 practical examples

Shell Scripting Class 2 variables

All Scripting Classes

Thanks for your wonderful Support and Encouragement

Ankam Ravi Kumar

Working as Linux / Storage Administrator L3. Interested in sharing the knowledge.

Leave a Reply

Your email address will not be published. Required fields are marked *