Bash Commands of Linux 
Shell Scripting in Linux

"Before moving to Linux basic commands, first of we should know about the command shell."


 What is a command shell? 


  1. A program that interprets commands.  
  2.  It allows a user to execute commands by typing them manually at a terminal, or automatically in programs called shell scripts.  
  3. A shell is not an operating system. It is a way to interface with the operating system and run commands. 

 What is BASH? 

1. BASH = Bourne Again SHell. 

2. Bash is a shell written as a free replacement to the standard Bourne Shell (/bin/sh) originally written by Steve Bourne for UNIX systems. It has all of the features of the original Bourne Shell, plus additions that make it easier to program with and use from the command line. 

 How is BASH different from the DOS command prompt? 


BASH VS DOS
BASH VS DOS

Basic Terminal Shortcuts:

Before we continue to learn about Linux shell commands, it is important to know that there are many shortcuts that we are using to control terminal in Linux/UNIX. 

Basic Linux Shortcuts
Getting Starting with Code (Shell Scripting):

comments are write using # for example:
#this is comment 


For example, the following creates a shell variable and then prints it:
variable ="Hello"
echo $variable
#Reading input form user
read name
echo $name
Below is a small script which will use a variable.
#!/bin/sh
echo "what is your name?"
read name
echo "How do you do, $name?"
read remark
echo "I am $remark too!"
#printing arguments which are given at compile 

time 
echo $1 $2 $3 
#running commands using scripting 
echo $pwd
echo $ls
echo $home

Conditional Statements:

The conditionals we are referring to are of course, ifthen and else.  we can also implement conditioning in shell scripting to perform operations
operators and their details are given below:
Shell script conditioning 

Example code:
if/else conditioning code example 

Different loops in shell programming:
example program for For loop in shell programming:
for loop in shell programming
 while loop example in shell programming:
while loop in shell programming

until loop in the shell programming


let command:

Last but not the least we have let command in shell programming which use to compute expressions such as plus, minus, and all other arithmetic operations:
let command in shell programming
 



Assignment Question:

Q1. write a program do the following thing using shell script:
  1.  Take 3 names to form user
  2. Execute PWD, ls, touch
  3. Print all the names on the console
Q2. write a program do following thing using shell script:
  1.  print all the argument which are given while executing the output file 
  2. print the version of the bash 
  3. print the name of the working directory 

Today's Lab Tasks Submission:




Previous Lab Tasks Submission:

























1 Comments

Post a Comment

Previous Post Next Post