SlideShare a Scribd company logo
Day 3.
Editor/Filters.
Name of
Ananthi Murugesan
presentation
• Company name
Road Map

Vi editor

Filters and Other commands

Standard I/O Redirection

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Module 1
vi Editor

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

3
Objectives
Upon completing this module you should be able to understand the
following:
 What Is vi?
 Starting and Ending a vi Session
 Cursor Control Commands
 Input Mode: i, a, O, o
 Deleting Text: x, dw, dd, dG
 Copying, moving and changing Text
 Searching for Text: /, n, N

 Find and Replace

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

4
What Is vi?
• A screen-oriented text editor
•

Included with most UNIX system distributions

•

Command driven

•

Categories of commands include

General administration


Cursor movement



Insert text



Delete text



Paste text



Modify text
www.ananthim.wordpress.com

Author :- Ananthi Murugesan

5
Starting and Ending a vi Session
vi [filename] Start a vi edit session of file
Example:
$ vi testfile
- If the file doesn’t exist, it will be created
- Otherwise vi will open the existing file

All modifications are made to the copy of the file brought into memory.
Commands

Description

:wq or :x or <shift-zz>

write and quit

:w

write

:q

quit

:q!

Quit without saving

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

6
Cursor Control Commands
1G
<ctrl-b>
H
k
<up-arrow>

0
b,B
h
<left-arrow>

$
w,W
l
<right-arrow>

<down-arrow>
j
L
<ctrl-f>
G

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

7
Input Mode: i, a, O, o

i will insert character at the present cursor position
I will insert character at the beginning of the line
a will append character at the present cursor position
A will append character at the end of the line

o will insert a blank line below
O will insert a blank line above

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

8
Deleting Text: x, dw, dd, dG
x

deletes the current character

dw

deletes the current word

dd

deletes the current line

dG

delete all lines to end of file, including current line.

With any of these you can prefix a number

Example: 3dd will delete 3 lines

d$

to delete to the end of the line

d0

to delete to the start of the line

9

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Copying, moving and changing Text
yy

copy the line

yw

copy the word

p will paste the yanked lines below

dw

cut the word

P will paste the yanked lines above

dd

cut the line

r

will overwrite the current character

R

will replace all text on the right of the cursor position

cw

will replace only the current word

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

10
Searching for Text: /, n, N

/director will locate for the first occurrence of the
pattern ‘director’

n to locate the next occurrence
N to locate the previous occurence

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

11
Find and Replace
To find and replace the word director with member :
:1,$s/director/member/g
1,$ represents all lines in the file

g makes it truly global. g will ensure that all
occuences in each line is replaced. Without g only the
first occurrence of each line will be replaced.

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

12
Module 2
Filters & other commands

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

13
Objectives
Upon completing this module you should be able to understand the following:
•

grep, sort, find ,cut , tr

•

ftp

•

paste command

•

split command

•

uniq command

•

diff(Differential file comparator) Command

•

cmp command

•

file command

•

tar (tape archive program)

•

Restoring Files
www.ananthim.wordpress.com

Author :- Ananthi Murugesan

14
grep
Search for lines matching specified pattern
syntax:
grep [options] pattern [file1 file2 …..]
Example:
emp.dat
Robin

Bangalore

John

Chennai

Rina

Bangalore

$ grep Bangalore emp.dat
Robin

Bangalore

Rina

Bangalore

www.ananthim.wordpress.com

Author :- Ananthi Murugasen

15
grep with Regular Expressions
grep ‘regular_expression’ file

Valid metacharacters
.

Any single character

*

Zero or more occurences of the preceding character

[aA]

Enumeration: a or A

[a-f]

Any one of the characters in the range of a through f

^a

Any lines that start with a

z$

Any lines that end with z

www.ananthim.wordpress.com

Author :- Ananthi Murugasen

16
grep options
-v

print lines that do not match

-c

print only a count of matching lines

-l

print only the names of the files with matching lines

-n

number the matching lines

-i

ignore the case of letters when making comparisons

-w

do a whole word search

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

17
sort command
The sort command sorts lines and writes the result to standard output:

$ sort [ -t delimiter] [+field[.column]] [options]

Options:
-d
sorts in dictionary order. Only letters, digits and spaces are
considered in comparisons
-r

reverses the order of the specified sort

-n

sorts numeric fields in arithmetic value

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

18
sort examples
$ cat animals
dog.2
cat.4
elephant.10
rabbit.7
$ sort animals
cat.4
dog.2
elephant.10
rabbit.7
$ cat animals | sort +0.1
rabbit.7
cat.4
elephant.10
dog.2
$ cat animals | sort -t. -n +1
dog.2
cat.4
rabbit.7
elephant.10

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

19
find command
Search one or more directory structures for files that meet certain specified
criteria
Display the names of matching files or execute commands against those files
find path expression
Examples:
$ find / -name file1
---search for files in whole system with name
file1
$ find / -user user1 –exec rm { } ; ---search for the
files owned
by user1 and delete them
$ find / -user user1 –ok rm { } ;
---search for the
files owned by user1 and delete them
interactively

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

20
find options
-type

f
d

ordinary file
directory

-size

+n
-n
n

larger than "n" blocks
smaller than "n" blocks
equal to "n" blocks

-mtime

+x
-x

modified more than "x" days ago
modified less than "x" days ago

-perm

onum
mode

access permissions match "onum"
access permissin match "mode"

-user

user1

finds files owned by "user1"

-o

logical "or"

-newer

ref

searches for files that are newer than the
reference file.

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

21
tr command
Used to substitute the values

tr [a-z] [A-Z]

will convert each small letter to caps

cat test | tr [a-z] [A-Z] will convert the small letters to caps in display
tr –s “ “

will squeeze multiple space occurences of space into one

www.ananthim.wordpress.com

Author :- Ananthi Murgesan

22
ftp
The ftp Command Syntax :
$ ftp hostname
get
put
mget
mput
cd
lcd
ls
?
help command
bye

Gets a file from the remote
computer.
Sends a local file to the remote system
get multiple files from the remote system
Sends multiple files to the remote system
changes the directory in the remote system
changes the directory in the local system
Lists files on the remote computer.
Lists all ftp commands
Display a very brief help message for command.
Exits ftp.

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

23
The paste command
Used to paste files vertically
eg. file1

file2

paste file1 file2

name

address

age

name

address age

ram

mvm

29

ram

mvm

29

raghu

rjnagar

25

raghu

rjnagar

25

(To rearrange f1 f2 f3 to f3 f2 f1, cut each field,put into file then paste)
By default paste uses the tab character for pasting files, but –d to specify one
eg. paste –d | file1 file2
name

address|age

ram

mvm|29

raghu

rjnagar|25

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

24
The split command
Used to split up the files:

This command breaks up the input into several equi line segments.
by defalult, split breaks a file into 1000 line pieces(or whatever is left)
split creates files like xaa,xab,xac …. xaz then xba, xbb …. xbz and
… xzz . So there can be 676(26*26) files
split –5 chap

(here the chap file is broken into files of 5 lines size)

split chap small (the file names will be smallaa,smallab …. smallzz)

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

25
The uniq command
•

used in EDP environment

•

to clear the duplicate entries by mistakes

eg. dept.list

01|accounts|6213
01|accounts|6213
02|admin|5423
03|marketing|6521
03|marketing|6521

uniq dept.list

01|accounts|6213
02|admin|5423
03|marketing|6521

The input to uniq must be ordered data. So sort and send the data
sort dept.list | uniq -uniqlist (uniqlist is the output file)
www.ananthim.wordpress.com

Author :- Ananthi Murugesan

26
The diff(Differential file comparator)
Command

Analyzes text files
Reports the differences between files

diff [-options] file1 file2

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

27
The cmp command
$ cmp names names.old
names names.old differ: byte 6, line 1

$cmp -l names names.old
6 12 151
7 102 156
8 157 145
...
...
...
cmp: EOF on names

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

28
The file command
The file command tells the type of file

Example:
$ file /usr/bun/vi
/usr/bin/vi:executable (RISC system/6000) or object module
$ file c1
c1:
ascii text
$ file /usr/bin
/usr/bin: directory

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

29
tar (tape archive program)

create a disk archive that contains a group of files or an entire directory
structure
-c
-x
-t
-f

copy
extract
list
[only one can be present at a time]
to specify the device name

tar [–]cvf etc.tar /etc/*

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

30
Restoring Files
tar –xvf tarfile

Example:
tar –xvf etc.tar
selective extraction
tar –xvf etc.tar /etc/passwd
tar –tvf etc.tar will display the archive

www.ananthim.wordpress.com

Author :- Ananthi Murugesan

31
Module 3
Standard I/O Redirection

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Objectives
Upon completing this module you should be able to understand the following:
 The Standard Files

 Input Redirection
 Output Redirection
 Creating a file with cat
 Error Redirection
 Combined Redirection
 Split Outputs

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
The Standard Files
Standard Input File (0)

Keyboard

Standard Output File (1)

Monitor

Standard Error File (2)

Monitor

operators:
standard input redirection

0< or <

standard output redirection

1> or >

standard Error redirection

2>

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Input Redirection
Default standard input
$ mail user1
subject: Hi

Test mail
<ctrl-d>

Redirect Input from a file: <
$ mail user1 < letter

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Output Redirection
Default standard output:
$ ls
f1
f2
f3
Redirect output from a file: >
$ ls > ls.out
Redirecting and appending output to a file: >>
$ who >> who.out

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Creating a file with cat
While normally used to list the contents of files, using cat with
redirection can be used to create a file
$ ls
file1

file2

file3

Using redirection
$ cat > newfile
file created by using the output redirection
<ctrl-d>
$ ls
file1

file2

file3

newfile

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Combined Redirection
Combined redirects:
$ command > outfile 2>errfile <infile
$ command >> appendfile 2 >> errorfile <infile
Association Examples:
$ command > outfile 2 >&1

note: This is NOT the same as above
$ command 2>&1 >outfile

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Split Outputs

The tee command reads standard input and sends the data to
both standard output and a file.

Example:
$ ls | tee ls.save | wc –l

www.ananthim.wordpress.com

Author :- Ananthi Murugesan
Ad

More Related Content

What's hot (20)

Binary Tree Traversal
Binary Tree TraversalBinary Tree Traversal
Binary Tree Traversal
Dhrumil Panchal
 
Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions
Ahmed El-Arabawy
 
Linux kernel Architecture and Properties
Linux kernel Architecture and PropertiesLinux kernel Architecture and Properties
Linux kernel Architecture and Properties
Saadi Rahman
 
Basic commands of linux
Basic commands of linuxBasic commands of linux
Basic commands of linux
shravan saini
 
Mysql security 5.7
Mysql security 5.7 Mysql security 5.7
Mysql security 5.7
Mark Swarbrick
 
Container Performance Analysis Brendan Gregg, Netflix
Container Performance Analysis Brendan Gregg, NetflixContainer Performance Analysis Brendan Gregg, Netflix
Container Performance Analysis Brendan Gregg, Netflix
Docker, Inc.
 
Directory services
Directory servicesDirectory services
Directory services
Christalin Nelson
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
Nikhil Jain
 
Linux : Booting and runlevels
Linux : Booting and runlevelsLinux : Booting and runlevels
Linux : Booting and runlevels
John Ombagi
 
Samba server
Samba serverSamba server
Samba server
Santosh Khadsare
 
Files
FilesFiles
Files
kirtidhamija16
 
Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scripting
Corrado Santoro
 
The Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOsThe Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOs
Divye Kapoor
 
Linux command ppt
Linux command pptLinux command ppt
Linux command ppt
kalyanineve
 
NTFS file system
NTFS file systemNTFS file system
NTFS file system
Ravi Yasas
 
Infix to postfix expression in ds
Infix to postfix expression in dsInfix to postfix expression in ds
Infix to postfix expression in ds
Rohini Mahajan
 
Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating System
subhsikha
 
File system.
File system.File system.
File system.
elyza12
 
Disk and File System Management in Linux
Disk and File System Management in LinuxDisk and File System Management in Linux
Disk and File System Management in Linux
Henry Osborne
 
PostgreSQL Replication Tutorial
PostgreSQL Replication TutorialPostgreSQL Replication Tutorial
PostgreSQL Replication Tutorial
Hans-Jürgen Schönig
 
Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions
Ahmed El-Arabawy
 
Linux kernel Architecture and Properties
Linux kernel Architecture and PropertiesLinux kernel Architecture and Properties
Linux kernel Architecture and Properties
Saadi Rahman
 
Basic commands of linux
Basic commands of linuxBasic commands of linux
Basic commands of linux
shravan saini
 
Container Performance Analysis Brendan Gregg, Netflix
Container Performance Analysis Brendan Gregg, NetflixContainer Performance Analysis Brendan Gregg, Netflix
Container Performance Analysis Brendan Gregg, Netflix
Docker, Inc.
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
Nikhil Jain
 
Linux : Booting and runlevels
Linux : Booting and runlevelsLinux : Booting and runlevels
Linux : Booting and runlevels
John Ombagi
 
Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scripting
Corrado Santoro
 
The Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOsThe Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOs
Divye Kapoor
 
Linux command ppt
Linux command pptLinux command ppt
Linux command ppt
kalyanineve
 
NTFS file system
NTFS file systemNTFS file system
NTFS file system
Ravi Yasas
 
Infix to postfix expression in ds
Infix to postfix expression in dsInfix to postfix expression in ds
Infix to postfix expression in ds
Rohini Mahajan
 
Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating System
subhsikha
 
File system.
File system.File system.
File system.
elyza12
 
Disk and File System Management in Linux
Disk and File System Management in LinuxDisk and File System Management in Linux
Disk and File System Management in Linux
Henry Osborne
 

Viewers also liked (20)

Linux.ppt
Linux.ppt Linux.ppt
Linux.ppt
onu9
 
Unix - Shell Scripts
Unix - Shell ScriptsUnix - Shell Scripts
Unix - Shell Scripts
ananthimurugesan
 
60761 linux
60761 linux60761 linux
60761 linux
Ritika Ahlawat
 
Unix Introduction
Unix IntroductionUnix Introduction
Unix Introduction
ananthimurugesan
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
Utkarsh Sengar
 
Chap 17 advfs
Chap 17 advfsChap 17 advfs
Chap 17 advfs
Kenny (netman)
 
Linux fundamental - Chap 16 System Rescue
Linux fundamental - Chap 16 System RescueLinux fundamental - Chap 16 System Rescue
Linux fundamental - Chap 16 System Rescue
Kenny (netman)
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
Tushar Jain
 
Chap 18 net
Chap 18 netChap 18 net
Chap 18 net
Kenny (netman)
 
Ras pioverview
Ras pioverviewRas pioverview
Ras pioverview
Alec Clews
 
Linux pipe & redirection
Linux pipe & redirectionLinux pipe & redirection
Linux pipe & redirection
Colin Su
 
Linux network monitoring hands-on pratice
Linux network monitoring hands-on praticeLinux network monitoring hands-on pratice
Linux network monitoring hands-on pratice
Kenny (netman)
 
Linux fundamentals
Linux fundamentalsLinux fundamentals
Linux fundamentals
chakrikolla
 
Basics of-linux
Basics of-linuxBasics of-linux
Basics of-linux
Singsys Pte Ltd
 
Power point (asking permission)
Power point (asking permission)Power point (asking permission)
Power point (asking permission)
ahmaddarda1505
 
Chap 19 web
Chap 19 webChap 19 web
Chap 19 web
Kenny (netman)
 
Linux fundamental - Chap 05 filter
Linux fundamental - Chap 05 filterLinux fundamental - Chap 05 filter
Linux fundamental - Chap 05 filter
Kenny (netman)
 
Linux fundamental - Chap 13 account management
Linux fundamental - Chap 13 account managementLinux fundamental - Chap 13 account management
Linux fundamental - Chap 13 account management
Kenny (netman)
 
Linux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkgLinux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkg
Kenny (netman)
 
Linux fundamental - Chap 02 perm
Linux fundamental - Chap 02 permLinux fundamental - Chap 02 perm
Linux fundamental - Chap 02 perm
Kenny (netman)
 
Linux.ppt
Linux.ppt Linux.ppt
Linux.ppt
onu9
 
Linux fundamental - Chap 16 System Rescue
Linux fundamental - Chap 16 System RescueLinux fundamental - Chap 16 System Rescue
Linux fundamental - Chap 16 System Rescue
Kenny (netman)
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
Tushar Jain
 
Ras pioverview
Ras pioverviewRas pioverview
Ras pioverview
Alec Clews
 
Linux pipe & redirection
Linux pipe & redirectionLinux pipe & redirection
Linux pipe & redirection
Colin Su
 
Linux network monitoring hands-on pratice
Linux network monitoring hands-on praticeLinux network monitoring hands-on pratice
Linux network monitoring hands-on pratice
Kenny (netman)
 
Linux fundamentals
Linux fundamentalsLinux fundamentals
Linux fundamentals
chakrikolla
 
Power point (asking permission)
Power point (asking permission)Power point (asking permission)
Power point (asking permission)
ahmaddarda1505
 
Linux fundamental - Chap 05 filter
Linux fundamental - Chap 05 filterLinux fundamental - Chap 05 filter
Linux fundamental - Chap 05 filter
Kenny (netman)
 
Linux fundamental - Chap 13 account management
Linux fundamental - Chap 13 account managementLinux fundamental - Chap 13 account management
Linux fundamental - Chap 13 account management
Kenny (netman)
 
Linux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkgLinux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkg
Kenny (netman)
 
Linux fundamental - Chap 02 perm
Linux fundamental - Chap 02 permLinux fundamental - Chap 02 perm
Linux fundamental - Chap 02 perm
Kenny (netman)
 
Ad

Similar to Unix - Filters/Editors (20)

Group13
Group13Group13
Group13
21MX213OMRAJUV
 
50 Most Frequently Used UNIX Linux Commands -hmftj
50 Most Frequently Used UNIX  Linux Commands -hmftj50 Most Frequently Used UNIX  Linux Commands -hmftj
50 Most Frequently Used UNIX Linux Commands -hmftj
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
COMMAND.pptx
COMMAND.pptxCOMMAND.pptx
COMMAND.pptx
4AL20CS071MAYUR
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
Teja Bheemanapally
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
Teja Bheemanapally
 
Workshop on command line tools - day 1
Workshop on command line tools - day 1Workshop on command line tools - day 1
Workshop on command line tools - day 1
Leandro Lima
 
Linux System commands Essentialsand Basics.pptx
Linux System commands Essentialsand Basics.pptxLinux System commands Essentialsand Basics.pptx
Linux System commands Essentialsand Basics.pptx
mba1130feb2024
 
OS-Module 2 Linux Programming Important topics
OS-Module 2 Linux Programming Important topicsOS-Module 2 Linux Programming Important topics
OS-Module 2 Linux Programming Important topics
JithinS34
 
Unit 8 text processing tools
Unit 8 text processing toolsUnit 8 text processing tools
Unit 8 text processing tools
root_fibo
 
Chapter 3 Using Unix Commands
Chapter 3 Using Unix CommandsChapter 3 Using Unix Commands
Chapter 3 Using Unix Commands
MeenalJabde
 
Linux Command.pptx
Linux Command.pptxLinux Command.pptx
Linux Command.pptx
SaileshB5
 
Unix Tutorial
Unix TutorialUnix Tutorial
Unix Tutorial
Sanjay Saluth
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
GowthamRaju15
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
TECHWORLDwithphotoed
 
Examples -partII
Examples -partIIExamples -partII
Examples -partII
Kedar Bhandari
 
Prabu linux
Prabu linuxPrabu linux
Prabu linux
Prabu Cse
 
Prabu linux
Prabu linuxPrabu linux
Prabu linux
Prabu Cse
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
banubabitha
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
banubabitha
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
banubabitha
 
Ad

Recently uploaded (20)

AI You Can Trust: The Critical Role of Governance and Quality.pdf
AI You Can Trust: The Critical Role of Governance and Quality.pdfAI You Can Trust: The Critical Role of Governance and Quality.pdf
AI You Can Trust: The Critical Role of Governance and Quality.pdf
Precisely
 
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
BookNet Canada
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
Build With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdfBuild With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdf
Google Developer Group - Harare
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and MLGyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
Gyrus AI
 
Does Pornify Allow NSFW? Everything You Should Know
Does Pornify Allow NSFW? Everything You Should KnowDoes Pornify Allow NSFW? Everything You Should Know
Does Pornify Allow NSFW? Everything You Should Know
Pornify CC
 
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
CSUC - Consorci de Serveis Universitaris de Catalunya
 
AI You Can Trust: The Critical Role of Governance and Quality.pdf
AI You Can Trust: The Critical Role of Governance and Quality.pdfAI You Can Trust: The Critical Role of Governance and Quality.pdf
AI You Can Trust: The Critical Role of Governance and Quality.pdf
Precisely
 
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
BookNet Canada
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and MLGyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
Gyrus AI
 
Does Pornify Allow NSFW? Everything You Should Know
Does Pornify Allow NSFW? Everything You Should KnowDoes Pornify Allow NSFW? Everything You Should Know
Does Pornify Allow NSFW? Everything You Should Know
Pornify CC
 

Unix - Filters/Editors

  • 1. Day 3. Editor/Filters. Name of Ananthi Murugesan presentation • Company name
  • 2. Road Map Vi editor Filters and Other commands Standard I/O Redirection www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 4. Objectives Upon completing this module you should be able to understand the following:  What Is vi?  Starting and Ending a vi Session  Cursor Control Commands  Input Mode: i, a, O, o  Deleting Text: x, dw, dd, dG  Copying, moving and changing Text  Searching for Text: /, n, N  Find and Replace www.ananthim.wordpress.com Author :- Ananthi Murugesan 4
  • 5. What Is vi? • A screen-oriented text editor • Included with most UNIX system distributions • Command driven • Categories of commands include  General administration  Cursor movement  Insert text  Delete text  Paste text  Modify text www.ananthim.wordpress.com Author :- Ananthi Murugesan 5
  • 6. Starting and Ending a vi Session vi [filename] Start a vi edit session of file Example: $ vi testfile - If the file doesn’t exist, it will be created - Otherwise vi will open the existing file All modifications are made to the copy of the file brought into memory. Commands Description :wq or :x or <shift-zz> write and quit :w write :q quit :q! Quit without saving www.ananthim.wordpress.com Author :- Ananthi Murugesan 6
  • 8. Input Mode: i, a, O, o i will insert character at the present cursor position I will insert character at the beginning of the line a will append character at the present cursor position A will append character at the end of the line o will insert a blank line below O will insert a blank line above www.ananthim.wordpress.com Author :- Ananthi Murugesan 8
  • 9. Deleting Text: x, dw, dd, dG x deletes the current character dw deletes the current word dd deletes the current line dG delete all lines to end of file, including current line. With any of these you can prefix a number Example: 3dd will delete 3 lines d$ to delete to the end of the line d0 to delete to the start of the line 9 www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 10. Copying, moving and changing Text yy copy the line yw copy the word p will paste the yanked lines below dw cut the word P will paste the yanked lines above dd cut the line r will overwrite the current character R will replace all text on the right of the cursor position cw will replace only the current word www.ananthim.wordpress.com Author :- Ananthi Murugesan 10
  • 11. Searching for Text: /, n, N /director will locate for the first occurrence of the pattern ‘director’ n to locate the next occurrence N to locate the previous occurence www.ananthim.wordpress.com Author :- Ananthi Murugesan 11
  • 12. Find and Replace To find and replace the word director with member : :1,$s/director/member/g 1,$ represents all lines in the file g makes it truly global. g will ensure that all occuences in each line is replaced. Without g only the first occurrence of each line will be replaced. www.ananthim.wordpress.com Author :- Ananthi Murugesan 12
  • 13. Module 2 Filters & other commands www.ananthim.wordpress.com Author :- Ananthi Murugesan 13
  • 14. Objectives Upon completing this module you should be able to understand the following: • grep, sort, find ,cut , tr • ftp • paste command • split command • uniq command • diff(Differential file comparator) Command • cmp command • file command • tar (tape archive program) • Restoring Files www.ananthim.wordpress.com Author :- Ananthi Murugesan 14
  • 15. grep Search for lines matching specified pattern syntax: grep [options] pattern [file1 file2 …..] Example: emp.dat Robin Bangalore John Chennai Rina Bangalore $ grep Bangalore emp.dat Robin Bangalore Rina Bangalore www.ananthim.wordpress.com Author :- Ananthi Murugasen 15
  • 16. grep with Regular Expressions grep ‘regular_expression’ file Valid metacharacters . Any single character * Zero or more occurences of the preceding character [aA] Enumeration: a or A [a-f] Any one of the characters in the range of a through f ^a Any lines that start with a z$ Any lines that end with z www.ananthim.wordpress.com Author :- Ananthi Murugasen 16
  • 17. grep options -v print lines that do not match -c print only a count of matching lines -l print only the names of the files with matching lines -n number the matching lines -i ignore the case of letters when making comparisons -w do a whole word search www.ananthim.wordpress.com Author :- Ananthi Murugesan 17
  • 18. sort command The sort command sorts lines and writes the result to standard output: $ sort [ -t delimiter] [+field[.column]] [options] Options: -d sorts in dictionary order. Only letters, digits and spaces are considered in comparisons -r reverses the order of the specified sort -n sorts numeric fields in arithmetic value www.ananthim.wordpress.com Author :- Ananthi Murugesan 18
  • 19. sort examples $ cat animals dog.2 cat.4 elephant.10 rabbit.7 $ sort animals cat.4 dog.2 elephant.10 rabbit.7 $ cat animals | sort +0.1 rabbit.7 cat.4 elephant.10 dog.2 $ cat animals | sort -t. -n +1 dog.2 cat.4 rabbit.7 elephant.10 www.ananthim.wordpress.com Author :- Ananthi Murugesan 19
  • 20. find command Search one or more directory structures for files that meet certain specified criteria Display the names of matching files or execute commands against those files find path expression Examples: $ find / -name file1 ---search for files in whole system with name file1 $ find / -user user1 –exec rm { } ; ---search for the files owned by user1 and delete them $ find / -user user1 –ok rm { } ; ---search for the files owned by user1 and delete them interactively www.ananthim.wordpress.com Author :- Ananthi Murugesan 20
  • 21. find options -type f d ordinary file directory -size +n -n n larger than "n" blocks smaller than "n" blocks equal to "n" blocks -mtime +x -x modified more than "x" days ago modified less than "x" days ago -perm onum mode access permissions match "onum" access permissin match "mode" -user user1 finds files owned by "user1" -o logical "or" -newer ref searches for files that are newer than the reference file. www.ananthim.wordpress.com Author :- Ananthi Murugesan 21
  • 22. tr command Used to substitute the values tr [a-z] [A-Z] will convert each small letter to caps cat test | tr [a-z] [A-Z] will convert the small letters to caps in display tr –s “ “ will squeeze multiple space occurences of space into one www.ananthim.wordpress.com Author :- Ananthi Murgesan 22
  • 23. ftp The ftp Command Syntax : $ ftp hostname get put mget mput cd lcd ls ? help command bye Gets a file from the remote computer. Sends a local file to the remote system get multiple files from the remote system Sends multiple files to the remote system changes the directory in the remote system changes the directory in the local system Lists files on the remote computer. Lists all ftp commands Display a very brief help message for command. Exits ftp. www.ananthim.wordpress.com Author :- Ananthi Murugesan 23
  • 24. The paste command Used to paste files vertically eg. file1 file2 paste file1 file2 name address age name address age ram mvm 29 ram mvm 29 raghu rjnagar 25 raghu rjnagar 25 (To rearrange f1 f2 f3 to f3 f2 f1, cut each field,put into file then paste) By default paste uses the tab character for pasting files, but –d to specify one eg. paste –d | file1 file2 name address|age ram mvm|29 raghu rjnagar|25 www.ananthim.wordpress.com Author :- Ananthi Murugesan 24
  • 25. The split command Used to split up the files: This command breaks up the input into several equi line segments. by defalult, split breaks a file into 1000 line pieces(or whatever is left) split creates files like xaa,xab,xac …. xaz then xba, xbb …. xbz and … xzz . So there can be 676(26*26) files split –5 chap (here the chap file is broken into files of 5 lines size) split chap small (the file names will be smallaa,smallab …. smallzz) www.ananthim.wordpress.com Author :- Ananthi Murugesan 25
  • 26. The uniq command • used in EDP environment • to clear the duplicate entries by mistakes eg. dept.list 01|accounts|6213 01|accounts|6213 02|admin|5423 03|marketing|6521 03|marketing|6521 uniq dept.list 01|accounts|6213 02|admin|5423 03|marketing|6521 The input to uniq must be ordered data. So sort and send the data sort dept.list | uniq -uniqlist (uniqlist is the output file) www.ananthim.wordpress.com Author :- Ananthi Murugesan 26
  • 27. The diff(Differential file comparator) Command Analyzes text files Reports the differences between files diff [-options] file1 file2 www.ananthim.wordpress.com Author :- Ananthi Murugesan 27
  • 28. The cmp command $ cmp names names.old names names.old differ: byte 6, line 1 $cmp -l names names.old 6 12 151 7 102 156 8 157 145 ... ... ... cmp: EOF on names www.ananthim.wordpress.com Author :- Ananthi Murugesan 28
  • 29. The file command The file command tells the type of file Example: $ file /usr/bun/vi /usr/bin/vi:executable (RISC system/6000) or object module $ file c1 c1: ascii text $ file /usr/bin /usr/bin: directory www.ananthim.wordpress.com Author :- Ananthi Murugesan 29
  • 30. tar (tape archive program) create a disk archive that contains a group of files or an entire directory structure -c -x -t -f copy extract list [only one can be present at a time] to specify the device name tar [–]cvf etc.tar /etc/* www.ananthim.wordpress.com Author :- Ananthi Murugesan 30
  • 31. Restoring Files tar –xvf tarfile Example: tar –xvf etc.tar selective extraction tar –xvf etc.tar /etc/passwd tar –tvf etc.tar will display the archive www.ananthim.wordpress.com Author :- Ananthi Murugesan 31
  • 32. Module 3 Standard I/O Redirection www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 33. Objectives Upon completing this module you should be able to understand the following:  The Standard Files  Input Redirection  Output Redirection  Creating a file with cat  Error Redirection  Combined Redirection  Split Outputs www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 34. The Standard Files Standard Input File (0) Keyboard Standard Output File (1) Monitor Standard Error File (2) Monitor operators: standard input redirection 0< or < standard output redirection 1> or > standard Error redirection 2> www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 35. Input Redirection Default standard input $ mail user1 subject: Hi Test mail <ctrl-d> Redirect Input from a file: < $ mail user1 < letter www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 36. Output Redirection Default standard output: $ ls f1 f2 f3 Redirect output from a file: > $ ls > ls.out Redirecting and appending output to a file: >> $ who >> who.out www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 37. Creating a file with cat While normally used to list the contents of files, using cat with redirection can be used to create a file $ ls file1 file2 file3 Using redirection $ cat > newfile file created by using the output redirection <ctrl-d> $ ls file1 file2 file3 newfile www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 38. Combined Redirection Combined redirects: $ command > outfile 2>errfile <infile $ command >> appendfile 2 >> errorfile <infile Association Examples: $ command > outfile 2 >&1 note: This is NOT the same as above $ command 2>&1 >outfile www.ananthim.wordpress.com Author :- Ananthi Murugesan
  • 39. Split Outputs The tee command reads standard input and sends the data to both standard output and a file. Example: $ ls | tee ls.save | wc –l www.ananthim.wordpress.com Author :- Ananthi Murugesan
  翻译: