SlideShare a Scribd company logo
Using Vi Editor
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
What is vi
 The vi editor is elaborated as visual editor. It is installed in every Unix system.
In other words, it is available in all Linux distros. It is user-friendly and works
same on different distros and platforms. It is a very powerful application. An
improved version of vi editor is vim.
The vi editor has two modes:
 Command Mode: In command mode, actions are taken on the file. The vi
editor starts in command mode. Here, the typed words will act as commands in
vi editor. To pass a command, you need to be in command mode.
 Insert Mode: In insert mode, entered text will be inserted into the file.
The Esc key will take you to the command mode from insert mode.
By default, the vi editor starts in command mode. To enter text, you have to be
in insert mode, just type 'i' and you'll be in insert mode. Although, after
typing i nothing will appear on the screen but you'll be in insert mode. Now
you can type anything.
To exit from insert mode press Esc key, you'll be directed to command mode.
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
If you are not sure which mode you are in, press Esc key twice and you'll be in
command mode.
Using vi
 The vi editor tool is an interactive tool as it displays changes made in the file on
the screen while you edit the file.
 In vi editor you can insert, edit or remove a word as cursor moves throughout
the file.
 Commands are specified for each function like to delete it's x or dd.
 The vi editor is case-sensitive. For example, p allows you to paste after the
current line while P allows you to paste before the current line.
vi syntax: vi <fileName>
In the terminal when you'll type vi command with a file name, the terminal will
get clear and content of the file will be displayed. If there is no such file, then a
new file will be created and once completed file will be saved with the
mentioned file name.
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
To save and quit
 You can save and quit vi editor from command mode. Before writing save or
quit command you have to press colon (:). Colon allows you to give instructions
to vi.
exit vi table:
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Commands Action
:wq Save and quit
:w Save
:q Quit
:w fname Save as fname
ZZ Save and quit
:q! Quit discarding changes made
:w! Save (and write to non-writable file)
 To exit from vi, first ensure that you are in command mode. Now, type
:wq and press enter. It will save and quit vi.
 Type :wq to save and exit the file.
If you want to quit without saving the file, use :q. This command will
only work when you have not made any changes in the file.
Vi Commands
 Linux vi editor is different from other editors. You have to use different
keys to use different functions. Although, it's quite easy and interesting
to use vi editor.
 The vi editor commands are case sensitive.
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
 To switch from command to insert mode:
Command Action
i Start typing before the current character
I Start typing at the start of current line
a Start typing after the current character
A Start typing at the end of current line
o Start typing on a new line after the current line
O Start typing on a new line before the current line
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Commands Action
j To move down
k To move up
h To move left
l To move right
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
To jump lines:
Commands Action
G Will direct you at the last line of the
file
`` Will direct you to your last position in
the file
To delete:
Commands Action
x Delete the current character
X Delete the character before the
cursor
r Replace the current character
xp Switch two characters
dd Delete the current line
D Delete the current line from current
character to the end of the line
dG delete from the current line to the
end of the file
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
To repeat and undo:
Commands Action
u Undo the last command
. Repeat the last command
Command to cut, copy and paste:
Commands Action
dd Delete a line
yy (yank yank) copy a line
p Paste after the current line
P Paste before the current line
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Start and end of line:
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Commands Action
θ Bring at the start of the current
line
^ Bring at the start of the current
line
$ Bring at the end of the current line
dθ Delete till start of a line
d$ Delete till end of a line
Joining lines:
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Commands Action
J Join two lines
yyp Repeat the current line
ddp Swap two lines
 Move forward or backward:
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Commands Action
w Move one word forward
b Move one word backward
<n>w Move specified number of
words forward
dw Delete one word
yw Copy one word
<n>dw Delete specified number of
words
Search a string:
Commands Action
/string Forward search for given string
?string Backward search for given string
/^string Forward search string at beginning
of a line
/string$ Forward search string at end of a
line
n Go to next occurrence of searched
string
/<he> Search for the word he (and not for
there, here, etc.)
/pl[abc]ce Search for place, plbce, and plcce
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
3. Merge Redirection:
This allows you to redirect the output of a command or a program to a specific
file descriptor instead of standard output. the syntax for using this is “>&”
operator followed by the file descriptor number.
 “p >& q” Merges output from stream p with stream q
 “p <& q” Merges input from stream p with stream q
Connecting commands: Pipe.
A pipe is a form of redirection (transfer of standard output to some other
destination) that is used in Linux and other Unix-like operating systems to
send the output of one command/program/process to another
command/program/process for further processing.
The Unix/Linux systems allow stdout of a command to be connected to stdin of
another command. You can make it do so by using the pipe character ‘|’. Pipe is
used to combine two or more commands, and in this, the output of one
command acts as input to another command, and this command’s output may
act as input to the next command and so on.
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
 It can also be visualized as a temporary connection between two or more
commands/ programs/ processes. The command line programs that do the
further processing are referred to as filters.
 This direct connection between commands/ programs/ processes allows them
to operate simultaneously and permits data to be transferred between them
continuously rather than having to pass it through temporary text files or
through the display screen.
 Pipes are unidirectional i.e data flows from left to right through the
pipeline.
 Syntax : command_1 | command_2 | command_3 | .... | command_N
 Example :
1. Listing all files and directories and give it as input to more command.
 $ ls -l | more
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Shell Scripts:
 The basic concept of a shell script is a list of commands, which are listed in the
order of execution. A good shell script will have comments, preceded by a
pound sign, #,describing the steps.
 There are conditional tests, such as value A is greater than value B, loops
allowing us to go through massive amounts of data, files to read and store data,
and variables to read and store data, and the script may include functions.
 Shell scripts and functions are both interpreted. This means they are not
compiled.
 It supports less features. It supports input and output redirection operators.
Example Script:
 Assume we create a test.sh script. Note all the scripts would have .sh
extension.
 Before you add anything else to your script, you need to alert the system that a
shell
 script is being started. This is done using the shebang construct.
For example:
#!/bin/sh
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
This tells the system that the commands that follow are to be executed by the
Bourne shell. It's called a shebang because the # symbol is called a hash, and
the !symbol is called a bang.
 To create a script containing these commands, you put the shebang line first
and then add the commands:
#!/bin/bash
pwd
ls
Shell Comments:
You can put your comments in your script as follows:
#!/bin/bash
# this is sscasc
# Copyright (c)
sscasc.com #
Script follows
here: pwd
ls
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Now you save the above content and make this script executable as follows:
$chmod +x test.sh
Now you have your shell script ready to be executed as
follows: $./test.sh
Extended Shell Scripts:
 The shell is, after all, a real programming language, complete with variables,
control structures, and so forth. No matter how complicated a script gets,
however, it is still just a list of commands executed sequentially.
 Following script use the read command which takes the input from the
keyboard and assigns it as the value of the variable PERSON and finally prints
it on STDOUT.
echo "What is your name?"
read PERSON
echo "Hello,$PERSON"
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Job ID Versus Process ID
 Background and suspended processes are usually manipulated via job number
(job ID). This number is different from the process ID and is used because it is
shorter.
 In addition, a job can consist of multiple processes running in a series or at the
same time, in parallel. Using the job ID is easier than tracking individual
processes.
Nice command:-
 It is used to change or set the priority of a process
 syntax: $nice-value cat filename
 The default priority of a process in unix is 20
 The value range from 0 to 39, in linux-9 to 20.where 0 is high and 39 is lower
value.
 the default value of reduction is 10.
 The priority of a process can be increased only by administrator using double
minus(--).
 eg:-$nice--15catlast.txt
 The priority of a process can be made lower using the nice command.
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Here is sample run of the script:
 $./test.sh
 What is your
 name? vvfgc
 Hello, vvfgc
Variables:
 Variable is value that always changes during execution of a program. It is an
integral part of shell programming. They provide the ability to store and
manipulate information.
 There are 2 types of variables. They are
• Environment variables
• User defined variables
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Environment variables:
These variables are the part of the system and these are created and maintained
by the
system itself. These variables always in capital letters only.
Variable meaning
 PS1- this is first prompt setting in Unix ($)
 PS2- this is second prompt setting in Unix (>)
 PATH- whether we are used absolute or relative path.
 HOME- it stores the current root directory.
 LOGNAME-it stores the login name of the user.
User defined variable:
Variables are defined as follows::
variable_name = variable_value
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
For example:
NAME = "sscasc"
Above example defines the variable NAME and assigns it the value "sscasc".
Variables of this type are called scalar variables. A scalar variable can hold only
one value at a time.
The shell enables you to store any value you want in a variable. For example:
VAR1="ssczsc "
VAR2=100
Accessing Values to variables:
To access the value stored in a variable, prefix its name with the dollar sign ( $):
For example, following script would access the value of defined variable NAME
and would print it on STDOUT:
NAME="vvfgc "
echo $NAME
This would produce following value:
Output: vvfgc
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Read-only Variables:
 The shell provides a way to mark variables as read-only by using the “read
only”command. After a variable is marked read-only, its value cannot be
changed.
 For example, following script would give error while trying to change the value
of NAME:
NAME="vvfgc “
readonly NAME
NAME="Qadiri“
This would produce following result:
/bin/sh: NAME: This variable is read only.
Unsetting Variables:
 Unsetting or deleting a variable tells the shell to remove the variable from the
list of variables that it tracks. Once you unset a variable, you would not be able
to access stored value in the variable.
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Following is the syntax to unset a defined variable using the unset
command: unset variable_name
Above command would unset the value of a defined variable. Here is a simple
example
NAME="vvfgc"
unset
NAME
echo $NAME
Above example would not print anything. You cannot use the unset command to
unset variables that are marked readonly.
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Read command :
This command is used to take the input from the user.
Syntax: $read var1 var2 var3 ….. var n
Syntax: $ read var1
The variable used along with the read command need not be preceded by the
$ symbol.
Ex: clear echo “enter ur name”
read name
echo “hello $name”
Output: enter ur name :vvfgc
Hello vvfgc
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Expr command:
This command is used to perform mathematical caluculations.
Syntax: ` expr operand1 operator operand2 `
Where ( ` ) this symbol is known as grep symbol. There is always must a space
between symbol and the expr command.
Ex: clear echo “enter 2 numbers”
read a b
echo “ sum of 2 numbers is ` expr $a + $b ` “
echo “ sub of 2 numbers is ` expr $a - $b ` “
echo “ product of 2 numbers is ` expr $a * $b ` “
echo “ quotient of 2 numbers is ` expr $a /$b ` “
Note: In unix multiplication purpose we use the symbol of “*” because only * is
wild card character.
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Test operator [numerical test]
 Arithmetic Operators:
 There are following arithmetic operators supported by
Bourne Shell.
 Assume variable “a” holds 10 and variable “b” holds 20
then:
 Show Examples
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Operator Description Example
+ Addition - Adds values on either side of the operator `expr $a + $b` will give 30
- Subtraction - Subtracts right hand operand from left hand operand `expr $a -
$b` will give 10
* Multiplication - Multiplies values on either side of the operator `expr $a * $b`
will give 200/
/ Division - Divides left hand operand by right operand `expr $b / $a` will give 2
% Modulus - Divides left hand operand by right hand operand and returns
remainder `expr $b % $a` will give 0
=Assignment - Assign right operand in left a=$b would assign value of b into a
operand
= = Equality - Compares two numbers, if both are [ $a == $b ] would return same
then returns true. false.
!=Not Equality - Compares two numbers, if both [ $a != $b ] would return are
different then returns true. true.
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
 It is very important to note here that all the conditional expressions would be
put inside
 square braces with one spaces around them, for example [ $a == $b ] is correct
where as
 [$a==$b] is incorrect.
All the arithmetical calculations are done using long integers.
Relational Operators:
 Bourne Shell supports following relational operators which are specific to
numeric values.
 These operators would not work for string values unless their value is numeric.
 For example, following operators would work to check a relation between 10
and 20 as well as in between "10" and "20" but not in between "ten" and
"twenty".
 Assume variable “a” holds 10 and variable “b” holds 20 then:
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Operator Description Example:
-eq Checks if the value of two operands is equal or not, if yes then condition
becomes true. [ $a -eq $b ] is not true.
-ne Checks if the value of two operands is equal or not, if values are not equal
then condition becomes true [ $a -ne $b ] is true.
-gt Checks if the value of left operand is greater than the value of right operand, if
yes then condition becomes true. [ $a -gt $b ] is not true.
-lt Checks if the value of left operand is less than the value of right operand, if yes
then condition becomes true.[ $a -lt $b ] is true.
-ge Checks if the value of left operand is greater than or equal to the value of right
operand, if yes then condition becomes true.[ $a -ge $b ] is not true.
-le Checks if the value of left operand is less than or equal to the value of right
operand, if yes then condition becomes true [ $a -le $b ] is true.
 Note here that all the conditional expressions would be put inside square
braces with one spaces around them, for example [ $a <= $b ] is correct where as
[$a <= $b] is incorrect.
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
 Boolean Operators (or) logical operators:
 There are following Boolean operators supported by
Bourne Shell.
 Assume variable “a” holds 10 and variable “b” holds 20
then:
 Show Examples
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Operator Description Example
! This is logical negation. This inverts a true condition into false and vice versa.[ !
false ] is true.
-o This is logical OR. If one of the operands is true then condition would be true.[
$a -lt 20 - $b -gt 100 ] is true.
-a This is logical AND. If both the operands are true then condition would be true
otherwise it would be false.[ $a -lt 20 -a $b -gt 100 ] is false.
String test Operators
There are following string operators supported by Bourne Shell.
Assume variable a holds "abc" and variable b holds "efg" then:
Show Examples
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Operator Description Example
= Checks if the value of two operands is equal or not, if yes then condition
becomes true. [ $a = $b ] is not true.
!= Checks if the value of two operands is equal or not, if values are not equal then
condition becomes true.[ $a != $b ] is true.
-z Checks if the given string operand size is zero. [ -z $a ] is not true. If it is zero
length then it returns true.
-n Checks if the given string operand size is non- zero. If it is non-zero length
then it returns true. [ -n $a ] is true.
Check if str is not the empty string. If it is str empty then it returns false.[ $a ] is
not false.
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
File Test Operators
There are following operators to test various properties associated with a Unix
file.
Assume a variable file holds an existing file name "test" whose size is 100
bytes and has read, write and execute permission on:
Show Examples
Operator Description Example
b file Checks if file is a block special file if yes then condition becomes true. [ -b
$file ] is false.
-c file Checks if file is a character special file if yes then condition becomes true.[
-b $file ] is false.
-d file Check if file is a directory if yes then condition becomes true.[ -d $file ] is
not true.
-f file Check if file is an ordinary file as opposed to a directory or special file if yes
then condition becomes true. [ -f $file ] is true.
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
-g file Checks if file has its set group ID (SGID) bit set if yes then condition
becomes true. [ -g $file ] is false.
-k file Checks if file has its sticky bit set if yes then condition becomes true. [ -k
$file ] is false.
-p file Checks if file is a named pipe if yes then condition becomes true.[ -p $file ]
is false.
-t file Checks if file descriptor is open and associated
with a terminal if yes then condition becomes true.[ -t $file ]is false.
-u file Checks if file has its set user id (SUID) bit set if yes then condition
becomes true.[ -u $file ] is false.
-r file Checks if file is readable if yes then condition becomes true.[ -r $file ] is
true.
-w file Check if file is writable if yes then condition becomes true.[ -w $file ] is
true.
-x file Check if file is execute if yes then condition becomes true.[ -x $file ] is true.
-s file Check if file has size greater than 0 if yes then condition becomes true.[ -s
$file ] is true.
-e file Check if file exists. Is true even if file is a directory but exists.[ -e $file ] is
true.
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Control statements
The ability to control the flow of execution of program is known as control
statements . The different types of control structures are
 Sequence control structure
 Selection control structure
 Looping control structure
Selection control structure
This type of instruction allows the shell script to be executed depending on the
condition. There are mainly 4 types of decision making instructions. They are
 if-then-fi statement
 if-then-else-fi statement
 if-then-elif-then-else-fi statement case-esac statement
if-then-fi statement:
in this first check the condition. That condition is true then only the if block
statements will be executed otherwise the cursor transfer outside the if
condition.
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Syntax: ex:
if [ condition ] if [ $a –gt 18 ]
then then
statements echo “eligible for vote”
fi fi
if-then-else-fi statement:
in this first check the condition. That condition is true then only the if block
statements will be executed otherwise the else block statements will be executed.
Syntax: ex:
if [ condition ] if [ $a –gt $b ]
then then
statements echo “a is larger than b”
else else
statements echo “b is larger than a”
fi fi
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
if-then-elif-then-else-fi statement:
in this first check the condition. That condition is true then only the if block
statements will be executed otherwise the cursor checks the next condition
then the second condition will be true then inside that statements will be
executed and so on. If any conditions were not true then the else block
statements will be executed.
Syntax: ex:
if [ condition 1 ] if [ $a –gt $b –a $a –gt $c]
then then
statements echo ”a is larger”
elif [ condition 2] elif [ $b –gt $c ]
then then
statements echo “ b is larger”
else else
statements echo “c is larger”
fi fi
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Case-esac statement:
Syntax: case $variable in
[match1] )statements ; ;
[match2] statements ; ;
[match3] statements ; ;
: :
: :
*) statements ; ;
esac
here match1,match2 etc are the case labels.
• When a case statement is evaluated the value of variable is matched in any one
of the choices.
• When a match is found then shell executes that corresponding match
statements.
• The pair of semicolon at the end of every choices. It identifies break.
• *) indicates default class. Ex: clear echo “enter a character”
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
read ch
case $ch in
[a-z]) echo “entered character is lowercase letters” ; ;
[A-Z] echo “entered character is uppercase letters” ; ;
[0-9] echo “entered character isdigit” ; ;
*) echo “invalid choice” ;;
esac
Looping Control statements
In this all statements are executed repeatedly again and again as long as
condition is true.
This is also known as repetition or iteration.
Shell allows various types of looping. They are
• While loop
• Until loop
• For loop
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
While loop:
 This is the pretested loop or entry controlled loop. In this first check the
condition, if that condition was true then control enter inside the loop
otherwise control transferred outside the loop.
Syntax: ex:
while [ condition ] while [ i –le 10 ]
do do
Statements echo “$i”
done i =` expr $i + 1 `
done
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
until loop:
 This is also pretested loop or entry controlled loop. In this first check the
condition, if that condition was false then control enter inside the loop
otherwise control transferred outside the loop.
Syntax: ex:
until [ condition ] until [ i -ge 10 ]
do do
Statements echo “$i”
done i =`expr $i + 1 `
done
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
for loop:
This is a fixed execution loop. This loop is allow to execute list of statements
certain period of time.
Syntax:
for variable in value1 value2 value3….. value n do
statements
done
ex:
for i in 1 2 3 4 5
do
echo $i
i=` expr $i + 1 `
done
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Command line arguments.
 The Unix shell is used to run commands, and it allows users to pass run time
arguments to these commands.
 These arguments, also known as command line parameters, that allows the
users to either control the flow of the command or to specify the input data for
the command.
 While running a command, the user can pass a variable number of parameters
in the command line.
 Within the command script, the passed parameters are accessible using
‘positional parameters’. These range from $0 to $9, where $0 refers to the name
of the command itself, and $1 to $9 are the first through to the ninth parameter,
depending on how many parameters were actually passed.
Example:
$ sh hello how to do you do
Here $0 would be assigned sh
$1 would be assigned hello
$2 would be assigned how
And so on …
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Some additional commands to process these parameters.
1)Set
This command can be used to set the values of the positional parameters on
the command line.
Example:
$ set how do you do
$ echo $1 $2
how do
Here, “how” was assigned to $1 and “do” was assigned to $2 and so on.
2) shift
This command is used to shift the position of the positional parameters. i.e. $2
will be shifted to $1 all the way to the tenth parameter being shifted to $9. Note
that if in case there are more than 9 parameters, this mechanism can be used to
read beyond the 9th.
Example:
$ set hello good morning how do you do welcome to Unix tutorial.
Here, ‘hello’ is assigned to $1, ‘good’ to $2 and so on to ‘to’ being assigned to
$9. Now the shift command can be used to shift the parameters ‘N’ places.
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Example:
$ shift 2
$ echo $1
Now $1 will be ‘morning’ and so on to $8 being ‘unix’ and $9 being ‘tutorial’.
Special Parameters $* and $@
 There are special parameters that allow accessing all the command-line
arguments at once. $* and $@ both will act the same unless they are enclosed
in double quotes, "".
 Both the parameters specify the command-line arguments. However, the "$*"
special parameter takes the entire list as one argument with spaces between
and the "$@" special parameter takes the entire list and separates it into
separate arguments.
 We can write the shell script to process an unknown number of command line
arguments with either the $* or $@ special parameters −
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Exit Status
 The $? variable represents the exit status of the previous command.
 Exit status is a numerical value returned by every command upon its
completion. As a rule, most commands return an exit status of 0 if they were
successful, and 1 if they were unsuccessful.
 Some commands return additional exit statuses for particular reasons. For
example, some commands differentiate between kinds of errors and will return
various exit values depending on the specific type of failure.
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
Thanks !
Mrs.Harsha V Patil, MIT ACSC Alandi , Pune

More Related Content

Similar to Using Vi Editor.pptx

Shell Scripting and Programming.pptx
Shell Scripting and Programming.pptxShell Scripting and Programming.pptx
Shell Scripting and Programming.pptx
Harsha Patel
 
intro unix/linux 04
intro unix/linux 04intro unix/linux 04
intro unix/linux 04
duquoi
 
Linux programming - Getting self started
Linux programming - Getting self started Linux programming - Getting self started
Linux programming - Getting self started
Emertxe Information Technologies Pvt Ltd
 
Vi editor
Vi   editorVi   editor
Vi editor
Nidhi Sharma
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
GowthamRaju15
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
TECHWORLDwithphotoed
 
Using Unix Commands.pptx
Using Unix Commands.pptxUsing Unix Commands.pptx
Using Unix Commands.pptx
Harsha Patel
 
Using Unix Commands.pptx
Using Unix Commands.pptxUsing Unix Commands.pptx
Using Unix Commands.pptx
Harsha Patel
 
Operating System Practice : Meeting 7- working with bash shell-a-slide
Operating System Practice : Meeting 7- working with bash shell-a-slideOperating System Practice : Meeting 7- working with bash shell-a-slide
Operating System Practice : Meeting 7- working with bash shell-a-slide
Syaiful Ahdan
 
Foss manual (1)
Foss manual (1)Foss manual (1)
Foss manual (1)
Janagi Raman S
 
Introduction to vi editor
Introduction to vi editorIntroduction to vi editor
Introduction to vi editor
U.P Police
 
Text mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformaticsText mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformatics
BITS
 
changing and deleting text ,change word and line under vi editor
changing and deleting text ,change word and line under vi editorchanging and deleting text ,change word and line under vi editor
changing and deleting text ,change word and line under vi editor
Shourya Puri
 
C notes for exam preparation
C notes for exam preparationC notes for exam preparation
C notes for exam preparation
Lakshmi Sarvani Videla
 
Quick-Start-UNIX.pdf
Quick-Start-UNIX.pdfQuick-Start-UNIX.pdf
Quick-Start-UNIX.pdf
HODCA1
 
Nithi
NithiNithi
Nithi
sharmibalu
 
Unix Lec2
Unix Lec2Unix Lec2
Unix Lec2
Dr.Ravi
 
lectuer 21-22.pptx
lectuer 21-22.pptxlectuer 21-22.pptx
lectuer 21-22.pptx
poonam256394
 
lec4.docx
lec4.docxlec4.docx
lec4.docx
ismailaboshatra
 
Performance Teting - VU Scripting Using Rational (http://www.geektester.blogs...
Performance Teting - VU Scripting Using Rational (http://www.geektester.blogs...Performance Teting - VU Scripting Using Rational (http://www.geektester.blogs...
Performance Teting - VU Scripting Using Rational (http://www.geektester.blogs...
raj.kamal13
 

Similar to Using Vi Editor.pptx (20)

Shell Scripting and Programming.pptx
Shell Scripting and Programming.pptxShell Scripting and Programming.pptx
Shell Scripting and Programming.pptx
 
intro unix/linux 04
intro unix/linux 04intro unix/linux 04
intro unix/linux 04
 
Linux programming - Getting self started
Linux programming - Getting self started Linux programming - Getting self started
Linux programming - Getting self started
 
Vi editor
Vi   editorVi   editor
Vi editor
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
 
Using Unix Commands.pptx
Using Unix Commands.pptxUsing Unix Commands.pptx
Using Unix Commands.pptx
 
Using Unix Commands.pptx
Using Unix Commands.pptxUsing Unix Commands.pptx
Using Unix Commands.pptx
 
Operating System Practice : Meeting 7- working with bash shell-a-slide
Operating System Practice : Meeting 7- working with bash shell-a-slideOperating System Practice : Meeting 7- working with bash shell-a-slide
Operating System Practice : Meeting 7- working with bash shell-a-slide
 
Foss manual (1)
Foss manual (1)Foss manual (1)
Foss manual (1)
 
Introduction to vi editor
Introduction to vi editorIntroduction to vi editor
Introduction to vi editor
 
Text mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformaticsText mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformatics
 
changing and deleting text ,change word and line under vi editor
changing and deleting text ,change word and line under vi editorchanging and deleting text ,change word and line under vi editor
changing and deleting text ,change word and line under vi editor
 
C notes for exam preparation
C notes for exam preparationC notes for exam preparation
C notes for exam preparation
 
Quick-Start-UNIX.pdf
Quick-Start-UNIX.pdfQuick-Start-UNIX.pdf
Quick-Start-UNIX.pdf
 
Nithi
NithiNithi
Nithi
 
Unix Lec2
Unix Lec2Unix Lec2
Unix Lec2
 
lectuer 21-22.pptx
lectuer 21-22.pptxlectuer 21-22.pptx
lectuer 21-22.pptx
 
lec4.docx
lec4.docxlec4.docx
lec4.docx
 
Performance Teting - VU Scripting Using Rational (http://www.geektester.blogs...
Performance Teting - VU Scripting Using Rational (http://www.geektester.blogs...Performance Teting - VU Scripting Using Rational (http://www.geektester.blogs...
Performance Teting - VU Scripting Using Rational (http://www.geektester.blogs...
 

More from Harsha Patel

Introduction to Reinforcement Learning.pptx
Introduction to Reinforcement Learning.pptxIntroduction to Reinforcement Learning.pptx
Introduction to Reinforcement Learning.pptx
Harsha Patel
 
Introduction to Association Rules.pptx
Introduction  to  Association  Rules.pptxIntroduction  to  Association  Rules.pptx
Introduction to Association Rules.pptx
Harsha Patel
 
Introduction to Clustering . pptx
Introduction    to     Clustering . pptxIntroduction    to     Clustering . pptx
Introduction to Clustering . pptx
Harsha Patel
 
Introduction to Classification . pptx
Introduction  to   Classification . pptxIntroduction  to   Classification . pptx
Introduction to Classification . pptx
Harsha Patel
 
Introduction to Regression . pptx
Introduction     to    Regression . pptxIntroduction     to    Regression . pptx
Introduction to Regression . pptx
Harsha Patel
 
Intro of Machine Learning Models .pptx
Intro of Machine  Learning  Models .pptxIntro of Machine  Learning  Models .pptx
Intro of Machine Learning Models .pptx
Harsha Patel
 
Introduction to Machine Learning.pptx
Introduction  to  Machine  Learning.pptxIntroduction  to  Machine  Learning.pptx
Introduction to Machine Learning.pptx
Harsha Patel
 
Unit-V-Introduction to Data Mining.pptx
Unit-V-Introduction to  Data Mining.pptxUnit-V-Introduction to  Data Mining.pptx
Unit-V-Introduction to Data Mining.pptx
Harsha Patel
 
Unit-IV-Introduction to Data Warehousing .pptx
Unit-IV-Introduction to Data Warehousing .pptxUnit-IV-Introduction to Data Warehousing .pptx
Unit-IV-Introduction to Data Warehousing .pptx
Harsha Patel
 
Unit-III-AI Search Techniques and solution's
Unit-III-AI Search Techniques and solution'sUnit-III-AI Search Techniques and solution's
Unit-III-AI Search Techniques and solution's
Harsha Patel
 
Unit-II-Introduction of Artifiial Intelligence.pptx
Unit-II-Introduction of Artifiial Intelligence.pptxUnit-II-Introduction of Artifiial Intelligence.pptx
Unit-II-Introduction of Artifiial Intelligence.pptx
Harsha Patel
 
Unit-I-Introduction to Recent Trends.pptx
Unit-I-Introduction to Recent Trends.pptxUnit-I-Introduction to Recent Trends.pptx
Unit-I-Introduction to Recent Trends.pptx
Harsha Patel
 
Managing Processes in Unix.pptx
Managing Processes in Unix.pptxManaging Processes in Unix.pptx
Managing Processes in Unix.pptx
Harsha Patel
 
Introduction to Unix Concets.pptx
Introduction to Unix Concets.pptxIntroduction to Unix Concets.pptx
Introduction to Unix Concets.pptx
Harsha Patel
 
Handling Files Under Unix.pptx
Handling Files Under Unix.pptxHandling Files Under Unix.pptx
Handling Files Under Unix.pptx
Harsha Patel
 
Introduction to OS.pptx
Introduction to OS.pptxIntroduction to OS.pptx
Introduction to OS.pptx
Harsha Patel
 
Introduction to Unix Concets.pptx
Introduction to Unix Concets.pptxIntroduction to Unix Concets.pptx
Introduction to Unix Concets.pptx
Harsha Patel
 
Using Vi Editor.pptx
Using Vi Editor.pptxUsing Vi Editor.pptx
Using Vi Editor.pptx
Harsha Patel
 
Managing Processes in Unix.pptx
Managing Processes in Unix.pptxManaging Processes in Unix.pptx
Managing Processes in Unix.pptx
Harsha Patel
 
Handling Files Under Unix.pptx
Handling Files Under Unix.pptxHandling Files Under Unix.pptx
Handling Files Under Unix.pptx
Harsha Patel
 

More from Harsha Patel (20)

Introduction to Reinforcement Learning.pptx
Introduction to Reinforcement Learning.pptxIntroduction to Reinforcement Learning.pptx
Introduction to Reinforcement Learning.pptx
 
Introduction to Association Rules.pptx
Introduction  to  Association  Rules.pptxIntroduction  to  Association  Rules.pptx
Introduction to Association Rules.pptx
 
Introduction to Clustering . pptx
Introduction    to     Clustering . pptxIntroduction    to     Clustering . pptx
Introduction to Clustering . pptx
 
Introduction to Classification . pptx
Introduction  to   Classification . pptxIntroduction  to   Classification . pptx
Introduction to Classification . pptx
 
Introduction to Regression . pptx
Introduction     to    Regression . pptxIntroduction     to    Regression . pptx
Introduction to Regression . pptx
 
Intro of Machine Learning Models .pptx
Intro of Machine  Learning  Models .pptxIntro of Machine  Learning  Models .pptx
Intro of Machine Learning Models .pptx
 
Introduction to Machine Learning.pptx
Introduction  to  Machine  Learning.pptxIntroduction  to  Machine  Learning.pptx
Introduction to Machine Learning.pptx
 
Unit-V-Introduction to Data Mining.pptx
Unit-V-Introduction to  Data Mining.pptxUnit-V-Introduction to  Data Mining.pptx
Unit-V-Introduction to Data Mining.pptx
 
Unit-IV-Introduction to Data Warehousing .pptx
Unit-IV-Introduction to Data Warehousing .pptxUnit-IV-Introduction to Data Warehousing .pptx
Unit-IV-Introduction to Data Warehousing .pptx
 
Unit-III-AI Search Techniques and solution's
Unit-III-AI Search Techniques and solution'sUnit-III-AI Search Techniques and solution's
Unit-III-AI Search Techniques and solution's
 
Unit-II-Introduction of Artifiial Intelligence.pptx
Unit-II-Introduction of Artifiial Intelligence.pptxUnit-II-Introduction of Artifiial Intelligence.pptx
Unit-II-Introduction of Artifiial Intelligence.pptx
 
Unit-I-Introduction to Recent Trends.pptx
Unit-I-Introduction to Recent Trends.pptxUnit-I-Introduction to Recent Trends.pptx
Unit-I-Introduction to Recent Trends.pptx
 
Managing Processes in Unix.pptx
Managing Processes in Unix.pptxManaging Processes in Unix.pptx
Managing Processes in Unix.pptx
 
Introduction to Unix Concets.pptx
Introduction to Unix Concets.pptxIntroduction to Unix Concets.pptx
Introduction to Unix Concets.pptx
 
Handling Files Under Unix.pptx
Handling Files Under Unix.pptxHandling Files Under Unix.pptx
Handling Files Under Unix.pptx
 
Introduction to OS.pptx
Introduction to OS.pptxIntroduction to OS.pptx
Introduction to OS.pptx
 
Introduction to Unix Concets.pptx
Introduction to Unix Concets.pptxIntroduction to Unix Concets.pptx
Introduction to Unix Concets.pptx
 
Using Vi Editor.pptx
Using Vi Editor.pptxUsing Vi Editor.pptx
Using Vi Editor.pptx
 
Managing Processes in Unix.pptx
Managing Processes in Unix.pptxManaging Processes in Unix.pptx
Managing Processes in Unix.pptx
 
Handling Files Under Unix.pptx
Handling Files Under Unix.pptxHandling Files Under Unix.pptx
Handling Files Under Unix.pptx
 

Recently uploaded

Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
AWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptxAWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptx
HarisZaheer8
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
fredae14
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
alexjohnson7307
 
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStrDeep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
saastr
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
Intelisync
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 

Recently uploaded (20)

Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
AWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptxAWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptx
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
 
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStrDeep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 

Using Vi Editor.pptx

  • 1. Using Vi Editor Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 2. What is vi  The vi editor is elaborated as visual editor. It is installed in every Unix system. In other words, it is available in all Linux distros. It is user-friendly and works same on different distros and platforms. It is a very powerful application. An improved version of vi editor is vim. The vi editor has two modes:  Command Mode: In command mode, actions are taken on the file. The vi editor starts in command mode. Here, the typed words will act as commands in vi editor. To pass a command, you need to be in command mode.  Insert Mode: In insert mode, entered text will be inserted into the file. The Esc key will take you to the command mode from insert mode. By default, the vi editor starts in command mode. To enter text, you have to be in insert mode, just type 'i' and you'll be in insert mode. Although, after typing i nothing will appear on the screen but you'll be in insert mode. Now you can type anything. To exit from insert mode press Esc key, you'll be directed to command mode. Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 3. If you are not sure which mode you are in, press Esc key twice and you'll be in command mode. Using vi  The vi editor tool is an interactive tool as it displays changes made in the file on the screen while you edit the file.  In vi editor you can insert, edit or remove a word as cursor moves throughout the file.  Commands are specified for each function like to delete it's x or dd.  The vi editor is case-sensitive. For example, p allows you to paste after the current line while P allows you to paste before the current line. vi syntax: vi <fileName> In the terminal when you'll type vi command with a file name, the terminal will get clear and content of the file will be displayed. If there is no such file, then a new file will be created and once completed file will be saved with the mentioned file name. Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 4. To save and quit  You can save and quit vi editor from command mode. Before writing save or quit command you have to press colon (:). Colon allows you to give instructions to vi. exit vi table: Mrs.Harsha V Patil, MIT ACSC Alandi , Pune Commands Action :wq Save and quit :w Save :q Quit :w fname Save as fname ZZ Save and quit :q! Quit discarding changes made :w! Save (and write to non-writable file)
  • 5.  To exit from vi, first ensure that you are in command mode. Now, type :wq and press enter. It will save and quit vi.  Type :wq to save and exit the file. If you want to quit without saving the file, use :q. This command will only work when you have not made any changes in the file. Vi Commands  Linux vi editor is different from other editors. You have to use different keys to use different functions. Although, it's quite easy and interesting to use vi editor.  The vi editor commands are case sensitive. Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 6.  To switch from command to insert mode: Command Action i Start typing before the current character I Start typing at the start of current line a Start typing after the current character A Start typing at the end of current line o Start typing on a new line after the current line O Start typing on a new line before the current line Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 7. Commands Action j To move down k To move up h To move left l To move right Mrs.Harsha V Patil, MIT ACSC Alandi , Pune To jump lines: Commands Action G Will direct you at the last line of the file `` Will direct you to your last position in the file
  • 8. To delete: Commands Action x Delete the current character X Delete the character before the cursor r Replace the current character xp Switch two characters dd Delete the current line D Delete the current line from current character to the end of the line dG delete from the current line to the end of the file Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 9. To repeat and undo: Commands Action u Undo the last command . Repeat the last command Command to cut, copy and paste: Commands Action dd Delete a line yy (yank yank) copy a line p Paste after the current line P Paste before the current line Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 10. Start and end of line: Mrs.Harsha V Patil, MIT ACSC Alandi , Pune Commands Action θ Bring at the start of the current line ^ Bring at the start of the current line $ Bring at the end of the current line dθ Delete till start of a line d$ Delete till end of a line
  • 11. Joining lines: Mrs.Harsha V Patil, MIT ACSC Alandi , Pune Commands Action J Join two lines yyp Repeat the current line ddp Swap two lines
  • 12.  Move forward or backward: Mrs.Harsha V Patil, MIT ACSC Alandi , Pune Commands Action w Move one word forward b Move one word backward <n>w Move specified number of words forward dw Delete one word yw Copy one word <n>dw Delete specified number of words
  • 13. Search a string: Commands Action /string Forward search for given string ?string Backward search for given string /^string Forward search string at beginning of a line /string$ Forward search string at end of a line n Go to next occurrence of searched string /<he> Search for the word he (and not for there, here, etc.) /pl[abc]ce Search for place, plbce, and plcce Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 14. 3. Merge Redirection: This allows you to redirect the output of a command or a program to a specific file descriptor instead of standard output. the syntax for using this is “>&” operator followed by the file descriptor number.  “p >& q” Merges output from stream p with stream q  “p <& q” Merges input from stream p with stream q Connecting commands: Pipe. A pipe is a form of redirection (transfer of standard output to some other destination) that is used in Linux and other Unix-like operating systems to send the output of one command/program/process to another command/program/process for further processing. The Unix/Linux systems allow stdout of a command to be connected to stdin of another command. You can make it do so by using the pipe character ‘|’. Pipe is used to combine two or more commands, and in this, the output of one command acts as input to another command, and this command’s output may act as input to the next command and so on. Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 15.  It can also be visualized as a temporary connection between two or more commands/ programs/ processes. The command line programs that do the further processing are referred to as filters.  This direct connection between commands/ programs/ processes allows them to operate simultaneously and permits data to be transferred between them continuously rather than having to pass it through temporary text files or through the display screen.  Pipes are unidirectional i.e data flows from left to right through the pipeline.  Syntax : command_1 | command_2 | command_3 | .... | command_N  Example : 1. Listing all files and directories and give it as input to more command.  $ ls -l | more Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 16. Shell Scripts:  The basic concept of a shell script is a list of commands, which are listed in the order of execution. A good shell script will have comments, preceded by a pound sign, #,describing the steps.  There are conditional tests, such as value A is greater than value B, loops allowing us to go through massive amounts of data, files to read and store data, and variables to read and store data, and the script may include functions.  Shell scripts and functions are both interpreted. This means they are not compiled.  It supports less features. It supports input and output redirection operators. Example Script:  Assume we create a test.sh script. Note all the scripts would have .sh extension.  Before you add anything else to your script, you need to alert the system that a shell  script is being started. This is done using the shebang construct. For example: #!/bin/sh Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 17. This tells the system that the commands that follow are to be executed by the Bourne shell. It's called a shebang because the # symbol is called a hash, and the !symbol is called a bang.  To create a script containing these commands, you put the shebang line first and then add the commands: #!/bin/bash pwd ls Shell Comments: You can put your comments in your script as follows: #!/bin/bash # this is sscasc # Copyright (c) sscasc.com # Script follows here: pwd ls Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 18. Now you save the above content and make this script executable as follows: $chmod +x test.sh Now you have your shell script ready to be executed as follows: $./test.sh Extended Shell Scripts:  The shell is, after all, a real programming language, complete with variables, control structures, and so forth. No matter how complicated a script gets, however, it is still just a list of commands executed sequentially.  Following script use the read command which takes the input from the keyboard and assigns it as the value of the variable PERSON and finally prints it on STDOUT. echo "What is your name?" read PERSON echo "Hello,$PERSON" Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 19. Job ID Versus Process ID  Background and suspended processes are usually manipulated via job number (job ID). This number is different from the process ID and is used because it is shorter.  In addition, a job can consist of multiple processes running in a series or at the same time, in parallel. Using the job ID is easier than tracking individual processes. Nice command:-  It is used to change or set the priority of a process  syntax: $nice-value cat filename  The default priority of a process in unix is 20  The value range from 0 to 39, in linux-9 to 20.where 0 is high and 39 is lower value.  the default value of reduction is 10.  The priority of a process can be increased only by administrator using double minus(--).  eg:-$nice--15catlast.txt  The priority of a process can be made lower using the nice command. Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 20. Here is sample run of the script:  $./test.sh  What is your  name? vvfgc  Hello, vvfgc Variables:  Variable is value that always changes during execution of a program. It is an integral part of shell programming. They provide the ability to store and manipulate information.  There are 2 types of variables. They are • Environment variables • User defined variables Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 21. Environment variables: These variables are the part of the system and these are created and maintained by the system itself. These variables always in capital letters only. Variable meaning  PS1- this is first prompt setting in Unix ($)  PS2- this is second prompt setting in Unix (>)  PATH- whether we are used absolute or relative path.  HOME- it stores the current root directory.  LOGNAME-it stores the login name of the user. User defined variable: Variables are defined as follows:: variable_name = variable_value Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 22. For example: NAME = "sscasc" Above example defines the variable NAME and assigns it the value "sscasc". Variables of this type are called scalar variables. A scalar variable can hold only one value at a time. The shell enables you to store any value you want in a variable. For example: VAR1="ssczsc " VAR2=100 Accessing Values to variables: To access the value stored in a variable, prefix its name with the dollar sign ( $): For example, following script would access the value of defined variable NAME and would print it on STDOUT: NAME="vvfgc " echo $NAME This would produce following value: Output: vvfgc Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 23. Read-only Variables:  The shell provides a way to mark variables as read-only by using the “read only”command. After a variable is marked read-only, its value cannot be changed.  For example, following script would give error while trying to change the value of NAME: NAME="vvfgc “ readonly NAME NAME="Qadiri“ This would produce following result: /bin/sh: NAME: This variable is read only. Unsetting Variables:  Unsetting or deleting a variable tells the shell to remove the variable from the list of variables that it tracks. Once you unset a variable, you would not be able to access stored value in the variable. Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 24. Following is the syntax to unset a defined variable using the unset command: unset variable_name Above command would unset the value of a defined variable. Here is a simple example NAME="vvfgc" unset NAME echo $NAME Above example would not print anything. You cannot use the unset command to unset variables that are marked readonly. Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 25. Read command : This command is used to take the input from the user. Syntax: $read var1 var2 var3 ….. var n Syntax: $ read var1 The variable used along with the read command need not be preceded by the $ symbol. Ex: clear echo “enter ur name” read name echo “hello $name” Output: enter ur name :vvfgc Hello vvfgc Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 26. Expr command: This command is used to perform mathematical caluculations. Syntax: ` expr operand1 operator operand2 ` Where ( ` ) this symbol is known as grep symbol. There is always must a space between symbol and the expr command. Ex: clear echo “enter 2 numbers” read a b echo “ sum of 2 numbers is ` expr $a + $b ` “ echo “ sub of 2 numbers is ` expr $a - $b ` “ echo “ product of 2 numbers is ` expr $a * $b ` “ echo “ quotient of 2 numbers is ` expr $a /$b ` “ Note: In unix multiplication purpose we use the symbol of “*” because only * is wild card character. Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 27. Test operator [numerical test]  Arithmetic Operators:  There are following arithmetic operators supported by Bourne Shell.  Assume variable “a” holds 10 and variable “b” holds 20 then:  Show Examples Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 28. Operator Description Example + Addition - Adds values on either side of the operator `expr $a + $b` will give 30 - Subtraction - Subtracts right hand operand from left hand operand `expr $a - $b` will give 10 * Multiplication - Multiplies values on either side of the operator `expr $a * $b` will give 200/ / Division - Divides left hand operand by right operand `expr $b / $a` will give 2 % Modulus - Divides left hand operand by right hand operand and returns remainder `expr $b % $a` will give 0 =Assignment - Assign right operand in left a=$b would assign value of b into a operand = = Equality - Compares two numbers, if both are [ $a == $b ] would return same then returns true. false. !=Not Equality - Compares two numbers, if both [ $a != $b ] would return are different then returns true. true. Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 29.  It is very important to note here that all the conditional expressions would be put inside  square braces with one spaces around them, for example [ $a == $b ] is correct where as  [$a==$b] is incorrect. All the arithmetical calculations are done using long integers. Relational Operators:  Bourne Shell supports following relational operators which are specific to numeric values.  These operators would not work for string values unless their value is numeric.  For example, following operators would work to check a relation between 10 and 20 as well as in between "10" and "20" but not in between "ten" and "twenty".  Assume variable “a” holds 10 and variable “b” holds 20 then: Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 30. Operator Description Example: -eq Checks if the value of two operands is equal or not, if yes then condition becomes true. [ $a -eq $b ] is not true. -ne Checks if the value of two operands is equal or not, if values are not equal then condition becomes true [ $a -ne $b ] is true. -gt Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true. [ $a -gt $b ] is not true. -lt Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true.[ $a -lt $b ] is true. -ge Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true.[ $a -ge $b ] is not true. -le Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true [ $a -le $b ] is true.  Note here that all the conditional expressions would be put inside square braces with one spaces around them, for example [ $a <= $b ] is correct where as [$a <= $b] is incorrect. Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 31.  Boolean Operators (or) logical operators:  There are following Boolean operators supported by Bourne Shell.  Assume variable “a” holds 10 and variable “b” holds 20 then:  Show Examples Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 32. Operator Description Example ! This is logical negation. This inverts a true condition into false and vice versa.[ ! false ] is true. -o This is logical OR. If one of the operands is true then condition would be true.[ $a -lt 20 - $b -gt 100 ] is true. -a This is logical AND. If both the operands are true then condition would be true otherwise it would be false.[ $a -lt 20 -a $b -gt 100 ] is false. String test Operators There are following string operators supported by Bourne Shell. Assume variable a holds "abc" and variable b holds "efg" then: Show Examples Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 33. Operator Description Example = Checks if the value of two operands is equal or not, if yes then condition becomes true. [ $a = $b ] is not true. != Checks if the value of two operands is equal or not, if values are not equal then condition becomes true.[ $a != $b ] is true. -z Checks if the given string operand size is zero. [ -z $a ] is not true. If it is zero length then it returns true. -n Checks if the given string operand size is non- zero. If it is non-zero length then it returns true. [ -n $a ] is true. Check if str is not the empty string. If it is str empty then it returns false.[ $a ] is not false. Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 34. File Test Operators There are following operators to test various properties associated with a Unix file. Assume a variable file holds an existing file name "test" whose size is 100 bytes and has read, write and execute permission on: Show Examples Operator Description Example b file Checks if file is a block special file if yes then condition becomes true. [ -b $file ] is false. -c file Checks if file is a character special file if yes then condition becomes true.[ -b $file ] is false. -d file Check if file is a directory if yes then condition becomes true.[ -d $file ] is not true. -f file Check if file is an ordinary file as opposed to a directory or special file if yes then condition becomes true. [ -f $file ] is true. Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 35. -g file Checks if file has its set group ID (SGID) bit set if yes then condition becomes true. [ -g $file ] is false. -k file Checks if file has its sticky bit set if yes then condition becomes true. [ -k $file ] is false. -p file Checks if file is a named pipe if yes then condition becomes true.[ -p $file ] is false. -t file Checks if file descriptor is open and associated with a terminal if yes then condition becomes true.[ -t $file ]is false. -u file Checks if file has its set user id (SUID) bit set if yes then condition becomes true.[ -u $file ] is false. -r file Checks if file is readable if yes then condition becomes true.[ -r $file ] is true. -w file Check if file is writable if yes then condition becomes true.[ -w $file ] is true. -x file Check if file is execute if yes then condition becomes true.[ -x $file ] is true. -s file Check if file has size greater than 0 if yes then condition becomes true.[ -s $file ] is true. -e file Check if file exists. Is true even if file is a directory but exists.[ -e $file ] is true. Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 36. Control statements The ability to control the flow of execution of program is known as control statements . The different types of control structures are  Sequence control structure  Selection control structure  Looping control structure Selection control structure This type of instruction allows the shell script to be executed depending on the condition. There are mainly 4 types of decision making instructions. They are  if-then-fi statement  if-then-else-fi statement  if-then-elif-then-else-fi statement case-esac statement if-then-fi statement: in this first check the condition. That condition is true then only the if block statements will be executed otherwise the cursor transfer outside the if condition. Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 37. Syntax: ex: if [ condition ] if [ $a –gt 18 ] then then statements echo “eligible for vote” fi fi if-then-else-fi statement: in this first check the condition. That condition is true then only the if block statements will be executed otherwise the else block statements will be executed. Syntax: ex: if [ condition ] if [ $a –gt $b ] then then statements echo “a is larger than b” else else statements echo “b is larger than a” fi fi Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 38. if-then-elif-then-else-fi statement: in this first check the condition. That condition is true then only the if block statements will be executed otherwise the cursor checks the next condition then the second condition will be true then inside that statements will be executed and so on. If any conditions were not true then the else block statements will be executed. Syntax: ex: if [ condition 1 ] if [ $a –gt $b –a $a –gt $c] then then statements echo ”a is larger” elif [ condition 2] elif [ $b –gt $c ] then then statements echo “ b is larger” else else statements echo “c is larger” fi fi Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 39. Case-esac statement: Syntax: case $variable in [match1] )statements ; ; [match2] statements ; ; [match3] statements ; ; : : : : *) statements ; ; esac here match1,match2 etc are the case labels. • When a case statement is evaluated the value of variable is matched in any one of the choices. • When a match is found then shell executes that corresponding match statements. • The pair of semicolon at the end of every choices. It identifies break. • *) indicates default class. Ex: clear echo “enter a character” Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 40. read ch case $ch in [a-z]) echo “entered character is lowercase letters” ; ; [A-Z] echo “entered character is uppercase letters” ; ; [0-9] echo “entered character isdigit” ; ; *) echo “invalid choice” ;; esac Looping Control statements In this all statements are executed repeatedly again and again as long as condition is true. This is also known as repetition or iteration. Shell allows various types of looping. They are • While loop • Until loop • For loop Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 41. While loop:  This is the pretested loop or entry controlled loop. In this first check the condition, if that condition was true then control enter inside the loop otherwise control transferred outside the loop. Syntax: ex: while [ condition ] while [ i –le 10 ] do do Statements echo “$i” done i =` expr $i + 1 ` done Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 42. until loop:  This is also pretested loop or entry controlled loop. In this first check the condition, if that condition was false then control enter inside the loop otherwise control transferred outside the loop. Syntax: ex: until [ condition ] until [ i -ge 10 ] do do Statements echo “$i” done i =`expr $i + 1 ` done Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 43. for loop: This is a fixed execution loop. This loop is allow to execute list of statements certain period of time. Syntax: for variable in value1 value2 value3….. value n do statements done ex: for i in 1 2 3 4 5 do echo $i i=` expr $i + 1 ` done Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 44. Command line arguments.  The Unix shell is used to run commands, and it allows users to pass run time arguments to these commands.  These arguments, also known as command line parameters, that allows the users to either control the flow of the command or to specify the input data for the command.  While running a command, the user can pass a variable number of parameters in the command line.  Within the command script, the passed parameters are accessible using ‘positional parameters’. These range from $0 to $9, where $0 refers to the name of the command itself, and $1 to $9 are the first through to the ninth parameter, depending on how many parameters were actually passed. Example: $ sh hello how to do you do Here $0 would be assigned sh $1 would be assigned hello $2 would be assigned how And so on … Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 45. Some additional commands to process these parameters. 1)Set This command can be used to set the values of the positional parameters on the command line. Example: $ set how do you do $ echo $1 $2 how do Here, “how” was assigned to $1 and “do” was assigned to $2 and so on. 2) shift This command is used to shift the position of the positional parameters. i.e. $2 will be shifted to $1 all the way to the tenth parameter being shifted to $9. Note that if in case there are more than 9 parameters, this mechanism can be used to read beyond the 9th. Example: $ set hello good morning how do you do welcome to Unix tutorial. Here, ‘hello’ is assigned to $1, ‘good’ to $2 and so on to ‘to’ being assigned to $9. Now the shift command can be used to shift the parameters ‘N’ places. Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 46. Example: $ shift 2 $ echo $1 Now $1 will be ‘morning’ and so on to $8 being ‘unix’ and $9 being ‘tutorial’. Special Parameters $* and $@  There are special parameters that allow accessing all the command-line arguments at once. $* and $@ both will act the same unless they are enclosed in double quotes, "".  Both the parameters specify the command-line arguments. However, the "$*" special parameter takes the entire list as one argument with spaces between and the "$@" special parameter takes the entire list and separates it into separate arguments.  We can write the shell script to process an unknown number of command line arguments with either the $* or $@ special parameters − Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 47. Exit Status  The $? variable represents the exit status of the previous command.  Exit status is a numerical value returned by every command upon its completion. As a rule, most commands return an exit status of 0 if they were successful, and 1 if they were unsuccessful.  Some commands return additional exit statuses for particular reasons. For example, some commands differentiate between kinds of errors and will return various exit values depending on the specific type of failure. Mrs.Harsha V Patil, MIT ACSC Alandi , Pune
  • 48. Thanks ! Mrs.Harsha V Patil, MIT ACSC Alandi , Pune