SlideShare a Scribd company logo
1 of 22
UNIT-III
Vi Editor,AWK Filters, Perl Manipulator
VI EDITOR
Vi editor is a visual screen editor which is available in almost all Unix systems. It is a
fast powerful editor.
Starting vi-
๏‚  to Start vi editor just type vi followed by the filename. Is the file is already exists
then it will show the contents of the file and allow you to edit them and if the file
dosent exist then it will create a new file.
๏‚  $ vi filename
MODES OFVI
1. Command mode: in this mode only commands will work to arrange, copy or
delete the data.Vi always start out in command mode and if you are working
and then you want to switch it back in command mode press ESC.
2. Insert mode: in this mode data can be enter into the file. By pressing โ€˜Iโ€™ will shift
you into the insert ode from command mode.
General command information:
Vi commands are
๏‚  Case sensitive
๏‚  Are not displayed on the screen when we type them.
๏‚  Generally do not require return after we type the command.
MOVING ONE CHARACTER AT ATIME:
h Left one space
i Right one space
j Down one space
k Up one space
MOVING AMONG WORDS AND LINES:
w Moves the cursor forward one word
b Moves the cursor backward one word
e Moves to the end of a word
ctrl+f Scrolls down one screen
ctrl+b Scrolls up one screen
ctrl+u Scrolls up half a screen
ctrl+d Scrolls down half a screen
Shortcuts: Two shortcuts for moving quickly on a line include $ and 0.
$ - will move us to the end of a line.
0 - will move us to the beginning of a line.
Screen Movement:
x Deletes the character under the cursor
X Deletes the character to the left of the cursor
dw Deletes the character selected to the end of the word
dd Deletes all the current line. (7dd โ€“ will deletes 7 lines)
D Deletes from the current character to the end of the line.
Yw Copies a word into buffer (7yw will copy 7 words)
Yy Copies a line into buffer (7yy will copy 7 lines)
P Will paste all the copied things.
Deleting Characters, Words and Lines:
Copying and Pasting text:
u Undoes the last change we made anywhere in the file
U Undoes all the recent changes to current line.
J To join lines (4J - to join 4 lines)
:w To save your file but not quit vi
:q To quit if we have not made any edits
:wq To quit and save edits
ZZ To quit and save edits (same as above)
:!q Force quit ( when it is not allowing you to quit file do force quit)
Quitting and Saving a File
Joining and Undoing a line
/ [string] Search forward for string
? [string] Search backward for string
N Repeat last search
:1,10w file Write lines 1 through 10 to file newfile
:sh Escape temporarily to a shell
^d Return from shell to vi
:set number Show line numbers
:set all Display current values of vi
Searching and Substitution Commands
Other Commands:
PROGRAMMING WITH AWK
๏‚  Awk is not just a command but a programming language too. It uses unusual
syntax that uses two components and requires single quotes and curly braces.
awk options โ€˜selection criteria {action}โ€™ files
๏‚  The selection criteria (a form of addressing) filters input and selects lines for the
action component to act on.This component is enclosed within curly braces.
๏‚  The address (rather than selection criteria) and action constitutes and awk
program that is surrounded by a set of single quotes.
awk โ€“F: โ€˜$3>200โ€™ { print $1, $3 }โ€™ /etc/passwd
Selection
Criteria
Action
Use to split fields with white spaces or on the delimiter specified with โ€“F option
SPLITTING A LINE INTO FIELDS
๏‚  AWK breaks-up a line into fields on whitespaces or on the de-limiter specified with
the โ€“F option. These fields are represented by the variables $1, $2, $3 and so forth.
$0 represents the full line.
๏‚  Since these parameters are evaluated by the shell in double quotes, awk
programs must be a single quoted.
$awk โ€“Fโ€|โ€ โ€˜/sales/ { print $2,$3,$4 } empn.lst
In the above line, awk will fetch all the records contains keyword โ€˜salesโ€™ and will
print second, third and fourth word from empn.lst.
COMPARISON OPERATORS
๏‚  $awk โ€“Fโ€|โ€ โ€˜$3 == โ€œdirectorโ€ || $3==โ€œchairmanโ€ empn.lst
- Prints the complete line.
๏‚  $awk โ€“Fโ€|โ€ โ€˜$3 == โ€œdirectorโ€ || $3==โ€œchairmanโ€ { printf โ€œ%-20s %-12s %dn, $2,$3, $6 }โ€
empn.lst
-prints the specific words.
John woodcook director 120000 20939
Barry wood chairman 160000 27288
John woodcook director 120000
Barry wood chairman 160000
Bill Johnson Director 130000
โ€ฆ
๏‚  $awk โ€“Fโ€|โ€ โ€˜$3 == โ€œdirectorโ€ || $3==โ€œchairmanโ€ { printf โ€œNR, %-20s %-12s %dn,
$2,$3, $6 }โ€ empn.lst
-NR is a new keyword which prints the line number.
๏‚  $awk โ€“Fโ€|โ€ โ€˜$6 > 120000 { printf โ€œNR, %-20s %-12s %dn, $2,$3, $6 }โ€ empn.lst
13 John woodcook director 120000
15 Barry wood chairman 160000
19 Bill Johnson Director 130000
COMPARISON OPERATORS
< LessThan
<= Less than or equal to
== Equal to
!= Not Equal to
>= Greater than or equal to
> Greater than
~ Matches a regular expression
!~ Does not match a regular expression
NUMBER PROCESSING
๏‚  Awk can perform computations on numbers using the arithmetic operators +, -,
*, / and % (modulus).
๏‚  Salespeople often earn a bonus apart from salary. We will assume here that the
bonus amount is equal one monthโ€™s salary.
$awk โ€“Fโ€|โ€ โ€˜$4 == โ€œsalesโ€ { printf โ€œNR, %-20s %-12s %6d %8.2fn,
NR,$2,$3,$6,$6/12 }โ€ empn.lst
13 John woodcook director 90000 7500.00
15 Barry wood chairman 140000 11666.67
19 Bill Johnson Director 110000 9166.67
VARIABLES
๏‚  AWK has certain built-in variables like,
๏‚  NR
๏‚  $0
๏‚  AWK provides user a flexibility to define own variables. It has two special feature-
๏‚  No type declarations are needed.
๏‚  By default and depending on its type, variables are initialized to zero or a null string.
AWK has a mechanism of identifying the typeof a variable used from its context.
$awk โ€“Fโ€|โ€ โ€˜$4 == โ€œsalesโ€ {
>kount = kount + 1
>printf โ€œNR, %-20s %-12s %6d %8.2fn,kount,NR,$2,$3,$6,$6/12 }โ€ empn.lst
1 13 John woodcook director 90000 7500.00
2 15 Barry wood chairman 140000 11666.67
BUILT-INVARIABLES
NR Cumulative number of lines read
FS Input field separator
OFS Output field separator
NF Number of fields in the current line
FILENAME Current input file
ARGC Number of arguments in command line
ARGV List of arguments
THE BEGIN AND END SECTIONS
๏‚  If you have to print something before you process the input, the BEGIN section
can be used quite gainfully. Similarly, the end section is equally useful for printing
some totals after the processing is over.
๏‚  BEGIN { action }
๏‚  END { action }
LETโ€™S DO A PROGRAM
๏‚  $cat emawk2.awk
BEGIN { printf โ€œntt Employee Detailsnnโ€
}
$6 > 12000 { #Increment variables for serial number and pay
kount++; total+-$6
printf โ€œ%3d %-20s %-12s %snโ€, kount,$2,$3,$6
}
END { printf โ€œntThe average salary is %6dnโ€, total/kount
}
EXECUTION & OUTPUT
๏‚  $ awk โ€“Fโ€|โ€ โ€“f empawk2.awk empn.lst
Employee Details
The average salary is 115000
1 John woodcook director 90000
2 Barry wood chairman 140000
ARRAYS
๏‚  Awk handles only one-dimensional arrays.
๏‚  No array declaration is required.
๏‚  It is automatically initialized to zero unless initialized explicitly.
$ cat empawk4.awk
BEGIN { FS = โ€œ|โ€ ; printf โ€œ%40snโ€, โ€œSalary Commissionโ€ }
/sales/ {
commission = $6*0.20
tot[1]+=$6; tot[2]+=commission
kount++;
}
END { printf โ€œT Average %5d %5dnโ€, tot[1]/kount, tot[2]/kount
}
OUTPUT
$ awk โ€“f empawk4.awk empn.lst
Salary Commission
Average 105625 21125
FUNCTIONS
๏‚  AWK has several built-in functions performing both arithmetic and string
operations.
$ awk โ€“Fโ€|โ€ โ€˜length($2) < 11โ€™ empn.lst
It will search those people who have short names.
int(x) Returns integer value of x
sqrt(x) Returns the square root of x
length Returns length of complete line
length($x) Returns length of x
substr(stg,m,n) Returns portion of string length n, starting from position m in a string stg
index(s1,s2) Returns position of string s2 in string s1
split(stg,arr,ch) Split string stg into array arr using ch as delimiter; optionally returns number of fields
system(โ€œcmdโ€) Runs UNIX command cmd, and returns its exit status
THANKS

More Related Content

What's hot

Aggregate function
Aggregate functionAggregate function
Aggregate functionRayhan Chowdhury
ย 
Php Chapter 1 Training
Php Chapter 1 TrainingPhp Chapter 1 Training
Php Chapter 1 TrainingChris Chubb
ย 
Mesics lecture 5 input โ€“ output in โ€˜cโ€™
Mesics lecture 5   input โ€“ output in โ€˜cโ€™Mesics lecture 5   input โ€“ output in โ€˜cโ€™
Mesics lecture 5 input โ€“ output in โ€˜cโ€™eShikshak
ย 
C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5Rumman Ansari
ย 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8Rumman Ansari
ย 
Swift 3.0 ใฎๆ–ฐใ—ใ„ๆฉŸ่ƒฝ๏ผˆใฎใ†ใกใฎ๏ผ™ใค๏ผ‰
Swift 3.0 ใฎๆ–ฐใ—ใ„ๆฉŸ่ƒฝ๏ผˆใฎใ†ใกใฎ๏ผ™ใค๏ผ‰Swift 3.0 ใฎๆ–ฐใ—ใ„ๆฉŸ่ƒฝ๏ผˆใฎใ†ใกใฎ๏ผ™ใค๏ผ‰
Swift 3.0 ใฎๆ–ฐใ—ใ„ๆฉŸ่ƒฝ๏ผˆใฎใ†ใกใฎ๏ผ™ใค๏ผ‰Tomohiro Kumagai
ย 
Lab4 join - all types listed
Lab4   join - all types listedLab4   join - all types listed
Lab4 join - all types listedBalqees Al.Mubarak
ย 
Abap 7 02 new features - new string functions
Abap 7 02   new features - new string functionsAbap 7 02   new features - new string functions
Abap 7 02 new features - new string functionsCadaxo GmbH
ย 
F# intro
F# introF# intro
F# introAlexey Raga
ย 
Diploma ii cfpc u-4 function, storage class and array and strings
Diploma ii  cfpc u-4 function, storage class and array and stringsDiploma ii  cfpc u-4 function, storage class and array and strings
Diploma ii cfpc u-4 function, storage class and array and stringsRai University
ย 
Mcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and stringsMcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and stringsRai University
ย 
Decent exposure: Controladores sin @ivars
Decent exposure: Controladores sin @ivarsDecent exposure: Controladores sin @ivars
Decent exposure: Controladores sin @ivarsLeonardo Soto
ย 
Bsc cs i pic u-4 function, storage class and array and strings
Bsc cs i pic u-4 function, storage class and array and stringsBsc cs i pic u-4 function, storage class and array and strings
Bsc cs i pic u-4 function, storage class and array and stringsRai University
ย 
Open SQL & Internal Table
Open SQL & Internal TableOpen SQL & Internal Table
Open SQL & Internal Tablesapdocs. info
ย 

What's hot (20)

Aggregate function
Aggregate functionAggregate function
Aggregate function
ย 
Les18
Les18Les18
Les18
ย 
Php Chapter 1 Training
Php Chapter 1 TrainingPhp Chapter 1 Training
Php Chapter 1 Training
ย 
Mesics lecture 5 input โ€“ output in โ€˜cโ€™
Mesics lecture 5   input โ€“ output in โ€˜cโ€™Mesics lecture 5   input โ€“ output in โ€˜cโ€™
Mesics lecture 5 input โ€“ output in โ€˜cโ€™
ย 
Les04
Les04Les04
Les04
ย 
Oracle: Functions
Oracle: FunctionsOracle: Functions
Oracle: Functions
ย 
C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5
ย 
Single row functions
Single row functionsSingle row functions
Single row functions
ย 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
ย 
Swift 3.0 ใฎๆ–ฐใ—ใ„ๆฉŸ่ƒฝ๏ผˆใฎใ†ใกใฎ๏ผ™ใค๏ผ‰
Swift 3.0 ใฎๆ–ฐใ—ใ„ๆฉŸ่ƒฝ๏ผˆใฎใ†ใกใฎ๏ผ™ใค๏ผ‰Swift 3.0 ใฎๆ–ฐใ—ใ„ๆฉŸ่ƒฝ๏ผˆใฎใ†ใกใฎ๏ผ™ใค๏ผ‰
Swift 3.0 ใฎๆ–ฐใ—ใ„ๆฉŸ่ƒฝ๏ผˆใฎใ†ใกใฎ๏ผ™ใค๏ผ‰
ย 
Lab4 join - all types listed
Lab4   join - all types listedLab4   join - all types listed
Lab4 join - all types listed
ย 
Abap 7 02 new features - new string functions
Abap 7 02   new features - new string functionsAbap 7 02   new features - new string functions
Abap 7 02 new features - new string functions
ย 
Les03
Les03Les03
Les03
ย 
F# intro
F# introF# intro
F# intro
ย 
Les04
Les04Les04
Les04
ย 
Diploma ii cfpc u-4 function, storage class and array and strings
Diploma ii  cfpc u-4 function, storage class and array and stringsDiploma ii  cfpc u-4 function, storage class and array and strings
Diploma ii cfpc u-4 function, storage class and array and strings
ย 
Mcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and stringsMcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and strings
ย 
Decent exposure: Controladores sin @ivars
Decent exposure: Controladores sin @ivarsDecent exposure: Controladores sin @ivars
Decent exposure: Controladores sin @ivars
ย 
Bsc cs i pic u-4 function, storage class and array and strings
Bsc cs i pic u-4 function, storage class and array and stringsBsc cs i pic u-4 function, storage class and array and strings
Bsc cs i pic u-4 function, storage class and array and strings
ย 
Open SQL & Internal Table
Open SQL & Internal TableOpen SQL & Internal Table
Open SQL & Internal Table
ย 

Similar to VI Editor

Awk-An Advanced Filter
Awk-An Advanced FilterAwk-An Advanced Filter
Awk-An Advanced FilterTye Rausch
ย 
Beginning with vi text editor
Beginning with vi text editorBeginning with vi text editor
Beginning with vi text editorJose Pla
ย 
DataWeave 2.0 - MuleSoft CONNECT 2019
DataWeave 2.0 - MuleSoft CONNECT 2019DataWeave 2.0 - MuleSoft CONNECT 2019
DataWeave 2.0 - MuleSoft CONNECT 2019Sabrina Marechal
ย 
Mission vim possible
Mission vim possibleMission vim possible
Mission vim possibleSam Gottfried
ย 
Using Vi Editor.pptx
Using Vi Editor.pptxUsing Vi Editor.pptx
Using Vi Editor.pptxHarsha Patel
ย 
Using Vi Editor.pptx
Using Vi Editor.pptxUsing Vi Editor.pptx
Using Vi Editor.pptxHarsha Patel
ย 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowchartsSamuel Igbanogu
ย 
Hechsp 001 Chapter 2
Hechsp 001 Chapter 2Hechsp 001 Chapter 2
Hechsp 001 Chapter 2Brian Kelly
ย 
Prog1 chap1 and chap 2
Prog1 chap1 and chap 2Prog1 chap1 and chap 2
Prog1 chap1 and chap 2rowensCap
ย 
Call Execute For Everyone
Call Execute For EveryoneCall Execute For Everyone
Call Execute For EveryoneDaniel Boisvert
ย 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docxJavvajiVenkat
ย 
The Ring programming language version 1.9 book - Part 25 of 210
The Ring programming language version 1.9 book - Part 25 of 210The Ring programming language version 1.9 book - Part 25 of 210
The Ring programming language version 1.9 book - Part 25 of 210Mahmoud Samir Fayed
ย 
Excel tutorial
Excel tutorialExcel tutorial
Excel tutorialSayeedAsghar
ย 

Similar to VI Editor (20)

Awk-An Advanced Filter
Awk-An Advanced FilterAwk-An Advanced Filter
Awk-An Advanced Filter
ย 
Beginning with vi text editor
Beginning with vi text editorBeginning with vi text editor
Beginning with vi text editor
ย 
Logo tutorial
Logo tutorialLogo tutorial
Logo tutorial
ย 
DataWeave 2.0 - MuleSoft CONNECT 2019
DataWeave 2.0 - MuleSoft CONNECT 2019DataWeave 2.0 - MuleSoft CONNECT 2019
DataWeave 2.0 - MuleSoft CONNECT 2019
ย 
Mission vim possible
Mission vim possibleMission vim possible
Mission vim possible
ย 
Vi editor
Vi editorVi editor
Vi editor
ย 
Using Vi Editor.pptx
Using Vi Editor.pptxUsing Vi Editor.pptx
Using Vi Editor.pptx
ย 
Using Vi Editor.pptx
Using Vi Editor.pptxUsing Vi Editor.pptx
Using Vi Editor.pptx
ย 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowcharts
ย 
Hechsp 001 Chapter 2
Hechsp 001 Chapter 2Hechsp 001 Chapter 2
Hechsp 001 Chapter 2
ย 
Prog1 chap1 and chap 2
Prog1 chap1 and chap 2Prog1 chap1 and chap 2
Prog1 chap1 and chap 2
ย 
Vi editor
Vi editorVi editor
Vi editor
ย 
Call Execute For Everyone
Call Execute For EveryoneCall Execute For Everyone
Call Execute For Everyone
ย 
Linux class 15 26 oct 2021
Linux class 15   26 oct 2021Linux class 15   26 oct 2021
Linux class 15 26 oct 2021
ย 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
ย 
Presentation 2
Presentation 2Presentation 2
Presentation 2
ย 
Awk hints
Awk hintsAwk hints
Awk hints
ย 
Awk programming
Awk programming Awk programming
Awk programming
ย 
The Ring programming language version 1.9 book - Part 25 of 210
The Ring programming language version 1.9 book - Part 25 of 210The Ring programming language version 1.9 book - Part 25 of 210
The Ring programming language version 1.9 book - Part 25 of 210
ย 
Excel tutorial
Excel tutorialExcel tutorial
Excel tutorial
ย 

More from Nishant Munjal

Database Management System
Database Management SystemDatabase Management System
Database Management SystemNishant Munjal
ย 
Functions & Recursion
Functions & RecursionFunctions & Recursion
Functions & RecursionNishant Munjal
ย 
Array, string and pointer
Array, string and pointerArray, string and pointer
Array, string and pointerNishant Munjal
ย 
Programming in C
Programming in CProgramming in C
Programming in CNishant Munjal
ย 
Introduction to computers
Introduction to computersIntroduction to computers
Introduction to computersNishant Munjal
ย 
Unix Administration
Unix AdministrationUnix Administration
Unix AdministrationNishant Munjal
ย 
Shell Programming Concept
Shell Programming ConceptShell Programming Concept
Shell Programming ConceptNishant Munjal
ย 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to UnixNishant Munjal
ย 
Routing Techniques
Routing TechniquesRouting Techniques
Routing TechniquesNishant Munjal
ย 
Asynchronous Transfer Mode
Asynchronous Transfer ModeAsynchronous Transfer Mode
Asynchronous Transfer ModeNishant Munjal
ย 
Overview of Cloud Computing
Overview of Cloud ComputingOverview of Cloud Computing
Overview of Cloud ComputingNishant Munjal
ย 
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries InformationNishant Munjal
ย 
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization TechniquesNishant Munjal
ย 
Concurrency Control
Concurrency ControlConcurrency Control
Concurrency ControlNishant Munjal
ย 
Transaction Processing Concept
Transaction Processing ConceptTransaction Processing Concept
Transaction Processing ConceptNishant Munjal
ย 
Database Management System
Database Management SystemDatabase Management System
Database Management SystemNishant Munjal
ย 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model IntroductionNishant Munjal
ย 
Virtualization, A Concept Implementation of Cloud
Virtualization, A Concept Implementation of CloudVirtualization, A Concept Implementation of Cloud
Virtualization, A Concept Implementation of CloudNishant Munjal
ย 
Technical education benchmarks
Technical education benchmarksTechnical education benchmarks
Technical education benchmarksNishant Munjal
ย 
Bluemix Introduction
Bluemix IntroductionBluemix Introduction
Bluemix IntroductionNishant Munjal
ย 

More from Nishant Munjal (20)

Database Management System
Database Management SystemDatabase Management System
Database Management System
ย 
Functions & Recursion
Functions & RecursionFunctions & Recursion
Functions & Recursion
ย 
Array, string and pointer
Array, string and pointerArray, string and pointer
Array, string and pointer
ย 
Programming in C
Programming in CProgramming in C
Programming in C
ย 
Introduction to computers
Introduction to computersIntroduction to computers
Introduction to computers
ย 
Unix Administration
Unix AdministrationUnix Administration
Unix Administration
ย 
Shell Programming Concept
Shell Programming ConceptShell Programming Concept
Shell Programming Concept
ย 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
ย 
Routing Techniques
Routing TechniquesRouting Techniques
Routing Techniques
ย 
Asynchronous Transfer Mode
Asynchronous Transfer ModeAsynchronous Transfer Mode
Asynchronous Transfer Mode
ย 
Overview of Cloud Computing
Overview of Cloud ComputingOverview of Cloud Computing
Overview of Cloud Computing
ย 
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries Information
ย 
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization Techniques
ย 
Concurrency Control
Concurrency ControlConcurrency Control
Concurrency Control
ย 
Transaction Processing Concept
Transaction Processing ConceptTransaction Processing Concept
Transaction Processing Concept
ย 
Database Management System
Database Management SystemDatabase Management System
Database Management System
ย 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
ย 
Virtualization, A Concept Implementation of Cloud
Virtualization, A Concept Implementation of CloudVirtualization, A Concept Implementation of Cloud
Virtualization, A Concept Implementation of Cloud
ย 
Technical education benchmarks
Technical education benchmarksTechnical education benchmarks
Technical education benchmarks
ย 
Bluemix Introduction
Bluemix IntroductionBluemix Introduction
Bluemix Introduction
ย 

Recently uploaded

ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
ย 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
ย 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
ย 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spaintimesproduction05
ย 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
ย 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSrknatarajan
ย 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdfSuman Jyoti
ย 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
ย 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
ย 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLManishPatel169454
ย 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
ย 
Call Now โ‰ฝ 9953056974 โ‰ผ๐Ÿ” Call Girls In New Ashok Nagar โ‰ผ๐Ÿ” Delhi door step de...
Call Now โ‰ฝ 9953056974 โ‰ผ๐Ÿ” Call Girls In New Ashok Nagar  โ‰ผ๐Ÿ” Delhi door step de...Call Now โ‰ฝ 9953056974 โ‰ผ๐Ÿ” Call Girls In New Ashok Nagar  โ‰ผ๐Ÿ” Delhi door step de...
Call Now โ‰ฝ 9953056974 โ‰ผ๐Ÿ” Call Girls In New Ashok Nagar โ‰ผ๐Ÿ” Delhi door step de...9953056974 Low Rate Call Girls In Saket, Delhi NCR
ย 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
ย 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
ย 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
ย 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
ย 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
ย 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Christo Ananth
ย 

Recently uploaded (20)

ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ย 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
ย 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
ย 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
ย 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
ย 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
ย 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
ย 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
ย 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
ย 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
ย 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
ย 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
ย 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
ย 
Call Now โ‰ฝ 9953056974 โ‰ผ๐Ÿ” Call Girls In New Ashok Nagar โ‰ผ๐Ÿ” Delhi door step de...
Call Now โ‰ฝ 9953056974 โ‰ผ๐Ÿ” Call Girls In New Ashok Nagar  โ‰ผ๐Ÿ” Delhi door step de...Call Now โ‰ฝ 9953056974 โ‰ผ๐Ÿ” Call Girls In New Ashok Nagar  โ‰ผ๐Ÿ” Delhi door step de...
Call Now โ‰ฝ 9953056974 โ‰ผ๐Ÿ” Call Girls In New Ashok Nagar โ‰ผ๐Ÿ” Delhi door step de...
ย 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
ย 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
ย 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
ย 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
ย 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
ย 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
ย 

VI Editor

  • 2. VI EDITOR Vi editor is a visual screen editor which is available in almost all Unix systems. It is a fast powerful editor. Starting vi- ๏‚  to Start vi editor just type vi followed by the filename. Is the file is already exists then it will show the contents of the file and allow you to edit them and if the file dosent exist then it will create a new file. ๏‚  $ vi filename
  • 3. MODES OFVI 1. Command mode: in this mode only commands will work to arrange, copy or delete the data.Vi always start out in command mode and if you are working and then you want to switch it back in command mode press ESC. 2. Insert mode: in this mode data can be enter into the file. By pressing โ€˜Iโ€™ will shift you into the insert ode from command mode. General command information: Vi commands are ๏‚  Case sensitive ๏‚  Are not displayed on the screen when we type them. ๏‚  Generally do not require return after we type the command.
  • 4. MOVING ONE CHARACTER AT ATIME: h Left one space i Right one space j Down one space k Up one space
  • 5. MOVING AMONG WORDS AND LINES: w Moves the cursor forward one word b Moves the cursor backward one word e Moves to the end of a word ctrl+f Scrolls down one screen ctrl+b Scrolls up one screen ctrl+u Scrolls up half a screen ctrl+d Scrolls down half a screen Shortcuts: Two shortcuts for moving quickly on a line include $ and 0. $ - will move us to the end of a line. 0 - will move us to the beginning of a line. Screen Movement:
  • 6. x Deletes the character under the cursor X Deletes the character to the left of the cursor dw Deletes the character selected to the end of the word dd Deletes all the current line. (7dd โ€“ will deletes 7 lines) D Deletes from the current character to the end of the line. Yw Copies a word into buffer (7yw will copy 7 words) Yy Copies a line into buffer (7yy will copy 7 lines) P Will paste all the copied things. Deleting Characters, Words and Lines: Copying and Pasting text:
  • 7. u Undoes the last change we made anywhere in the file U Undoes all the recent changes to current line. J To join lines (4J - to join 4 lines) :w To save your file but not quit vi :q To quit if we have not made any edits :wq To quit and save edits ZZ To quit and save edits (same as above) :!q Force quit ( when it is not allowing you to quit file do force quit) Quitting and Saving a File Joining and Undoing a line
  • 8. / [string] Search forward for string ? [string] Search backward for string N Repeat last search :1,10w file Write lines 1 through 10 to file newfile :sh Escape temporarily to a shell ^d Return from shell to vi :set number Show line numbers :set all Display current values of vi Searching and Substitution Commands Other Commands:
  • 9. PROGRAMMING WITH AWK ๏‚  Awk is not just a command but a programming language too. It uses unusual syntax that uses two components and requires single quotes and curly braces. awk options โ€˜selection criteria {action}โ€™ files ๏‚  The selection criteria (a form of addressing) filters input and selects lines for the action component to act on.This component is enclosed within curly braces. ๏‚  The address (rather than selection criteria) and action constitutes and awk program that is surrounded by a set of single quotes. awk โ€“F: โ€˜$3>200โ€™ { print $1, $3 }โ€™ /etc/passwd Selection Criteria Action Use to split fields with white spaces or on the delimiter specified with โ€“F option
  • 10. SPLITTING A LINE INTO FIELDS ๏‚  AWK breaks-up a line into fields on whitespaces or on the de-limiter specified with the โ€“F option. These fields are represented by the variables $1, $2, $3 and so forth. $0 represents the full line. ๏‚  Since these parameters are evaluated by the shell in double quotes, awk programs must be a single quoted. $awk โ€“Fโ€|โ€ โ€˜/sales/ { print $2,$3,$4 } empn.lst In the above line, awk will fetch all the records contains keyword โ€˜salesโ€™ and will print second, third and fourth word from empn.lst.
  • 11. COMPARISON OPERATORS ๏‚  $awk โ€“Fโ€|โ€ โ€˜$3 == โ€œdirectorโ€ || $3==โ€œchairmanโ€ empn.lst - Prints the complete line. ๏‚  $awk โ€“Fโ€|โ€ โ€˜$3 == โ€œdirectorโ€ || $3==โ€œchairmanโ€ { printf โ€œ%-20s %-12s %dn, $2,$3, $6 }โ€ empn.lst -prints the specific words. John woodcook director 120000 20939 Barry wood chairman 160000 27288 John woodcook director 120000 Barry wood chairman 160000 Bill Johnson Director 130000
  • 12. โ€ฆ ๏‚  $awk โ€“Fโ€|โ€ โ€˜$3 == โ€œdirectorโ€ || $3==โ€œchairmanโ€ { printf โ€œNR, %-20s %-12s %dn, $2,$3, $6 }โ€ empn.lst -NR is a new keyword which prints the line number. ๏‚  $awk โ€“Fโ€|โ€ โ€˜$6 > 120000 { printf โ€œNR, %-20s %-12s %dn, $2,$3, $6 }โ€ empn.lst 13 John woodcook director 120000 15 Barry wood chairman 160000 19 Bill Johnson Director 130000
  • 13. COMPARISON OPERATORS < LessThan <= Less than or equal to == Equal to != Not Equal to >= Greater than or equal to > Greater than ~ Matches a regular expression !~ Does not match a regular expression
  • 14. NUMBER PROCESSING ๏‚  Awk can perform computations on numbers using the arithmetic operators +, -, *, / and % (modulus). ๏‚  Salespeople often earn a bonus apart from salary. We will assume here that the bonus amount is equal one monthโ€™s salary. $awk โ€“Fโ€|โ€ โ€˜$4 == โ€œsalesโ€ { printf โ€œNR, %-20s %-12s %6d %8.2fn, NR,$2,$3,$6,$6/12 }โ€ empn.lst 13 John woodcook director 90000 7500.00 15 Barry wood chairman 140000 11666.67 19 Bill Johnson Director 110000 9166.67
  • 15. VARIABLES ๏‚  AWK has certain built-in variables like, ๏‚  NR ๏‚  $0 ๏‚  AWK provides user a flexibility to define own variables. It has two special feature- ๏‚  No type declarations are needed. ๏‚  By default and depending on its type, variables are initialized to zero or a null string. AWK has a mechanism of identifying the typeof a variable used from its context. $awk โ€“Fโ€|โ€ โ€˜$4 == โ€œsalesโ€ { >kount = kount + 1 >printf โ€œNR, %-20s %-12s %6d %8.2fn,kount,NR,$2,$3,$6,$6/12 }โ€ empn.lst 1 13 John woodcook director 90000 7500.00 2 15 Barry wood chairman 140000 11666.67
  • 16. BUILT-INVARIABLES NR Cumulative number of lines read FS Input field separator OFS Output field separator NF Number of fields in the current line FILENAME Current input file ARGC Number of arguments in command line ARGV List of arguments
  • 17. THE BEGIN AND END SECTIONS ๏‚  If you have to print something before you process the input, the BEGIN section can be used quite gainfully. Similarly, the end section is equally useful for printing some totals after the processing is over. ๏‚  BEGIN { action } ๏‚  END { action }
  • 18. LETโ€™S DO A PROGRAM ๏‚  $cat emawk2.awk BEGIN { printf โ€œntt Employee Detailsnnโ€ } $6 > 12000 { #Increment variables for serial number and pay kount++; total+-$6 printf โ€œ%3d %-20s %-12s %snโ€, kount,$2,$3,$6 } END { printf โ€œntThe average salary is %6dnโ€, total/kount }
  • 19. EXECUTION & OUTPUT ๏‚  $ awk โ€“Fโ€|โ€ โ€“f empawk2.awk empn.lst Employee Details The average salary is 115000 1 John woodcook director 90000 2 Barry wood chairman 140000
  • 20. ARRAYS ๏‚  Awk handles only one-dimensional arrays. ๏‚  No array declaration is required. ๏‚  It is automatically initialized to zero unless initialized explicitly. $ cat empawk4.awk BEGIN { FS = โ€œ|โ€ ; printf โ€œ%40snโ€, โ€œSalary Commissionโ€ } /sales/ { commission = $6*0.20 tot[1]+=$6; tot[2]+=commission kount++; } END { printf โ€œT Average %5d %5dnโ€, tot[1]/kount, tot[2]/kount } OUTPUT $ awk โ€“f empawk4.awk empn.lst Salary Commission Average 105625 21125
  • 21. FUNCTIONS ๏‚  AWK has several built-in functions performing both arithmetic and string operations. $ awk โ€“Fโ€|โ€ โ€˜length($2) < 11โ€™ empn.lst It will search those people who have short names. int(x) Returns integer value of x sqrt(x) Returns the square root of x length Returns length of complete line length($x) Returns length of x substr(stg,m,n) Returns portion of string length n, starting from position m in a string stg index(s1,s2) Returns position of string s2 in string s1 split(stg,arr,ch) Split string stg into array arr using ch as delimiter; optionally returns number of fields system(โ€œcmdโ€) Runs UNIX command cmd, and returns its exit status