SlideShare une entreprise Scribd logo
1  sur  39
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

Contenu connexe

Tendances

A Quick Introduction to Linux
A Quick Introduction to LinuxA Quick Introduction to Linux
A Quick Introduction to LinuxTusharadri Sarkar
 
File Management in Operating Systems
File Management in Operating SystemsFile Management in Operating Systems
File Management in Operating Systemsvampugani
 
50 most frequently used unix linux commands (with examples)
50 most frequently used unix   linux commands (with examples)50 most frequently used unix   linux commands (with examples)
50 most frequently used unix linux commands (with examples)Rodrigo Maia
 
Linux User Management
Linux User ManagementLinux User Management
Linux User ManagementGaurav Mishra
 
Input output redirection linux
Input output redirection linuxInput output redirection linux
Input output redirection linuxTanishq Soni
 
Linux Directory Structure
Linux Directory StructureLinux Directory Structure
Linux Directory StructureKevin OBrien
 
User Administration in Linux
User Administration in LinuxUser Administration in Linux
User Administration in LinuxSAMUEL OJO
 
Linux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for BeginnersLinux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for BeginnersDavide Ciambelli
 

Tendances (20)

A Quick Introduction to Linux
A Quick Introduction to LinuxA Quick Introduction to Linux
A Quick Introduction to Linux
 
File Management in Operating Systems
File Management in Operating SystemsFile Management in Operating Systems
File Management in Operating Systems
 
Vi editor
Vi editorVi editor
Vi editor
 
Vi editor in linux
Vi editor in linuxVi editor in linux
Vi editor in linux
 
Linux file system
Linux file systemLinux file system
Linux file system
 
50 most frequently used unix linux commands (with examples)
50 most frequently used unix   linux commands (with examples)50 most frequently used unix   linux commands (with examples)
50 most frequently used unix linux commands (with examples)
 
Linux User Management
Linux User ManagementLinux User Management
Linux User Management
 
Kali linux commands
Kali linux commandsKali linux commands
Kali linux commands
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
 
Input output redirection linux
Input output redirection linuxInput output redirection linux
Input output redirection linux
 
Find and locate
Find and locateFind and locate
Find and locate
 
Linux Directory Structure
Linux Directory StructureLinux Directory Structure
Linux Directory Structure
 
Ubuntu – Linux Useful Commands
Ubuntu – Linux Useful CommandsUbuntu – Linux Useful Commands
Ubuntu – Linux Useful Commands
 
User Administration in Linux
User Administration in LinuxUser Administration in Linux
User Administration in Linux
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
Deadlock
DeadlockDeadlock
Deadlock
 
Users and groups
Users and groupsUsers and groups
Users and groups
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
 
Linux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for BeginnersLinux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for Beginners
 
File management
File managementFile management
File management
 

En vedette

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 RescueKenny (netman)
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08Tushar Jain
 
Ras pioverview
Ras pioverviewRas pioverview
Ras pioverviewAlec Clews
 
Linux pipe & redirection
Linux pipe & redirectionLinux pipe & redirection
Linux pipe & redirectionColin Su
 
Linux network monitoring hands-on pratice
Linux network monitoring hands-on praticeLinux network monitoring hands-on pratice
Linux network monitoring hands-on praticeKenny (netman)
 
Linux fundamentals
Linux fundamentalsLinux fundamentals
Linux fundamentalschakrikolla
 
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 filterKenny (netman)
 
Linux fundamental - Chap 13 account management
Linux fundamental - Chap 13 account managementLinux fundamental - Chap 13 account management
Linux fundamental - Chap 13 account managementKenny (netman)
 
Linux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkgLinux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkgKenny (netman)
 

En vedette (20)

Linux.ppt
Linux.ppt Linux.ppt
Linux.ppt
 
Unix - Shell Scripts
Unix - Shell ScriptsUnix - Shell Scripts
Unix - Shell Scripts
 
60761 linux
60761 linux60761 linux
60761 linux
 
Unix Introduction
Unix IntroductionUnix Introduction
Unix Introduction
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
Chap 17 advfs
Chap 17 advfsChap 17 advfs
Chap 17 advfs
 
Linux fundamental - Chap 16 System Rescue
Linux fundamental - Chap 16 System RescueLinux fundamental - Chap 16 System Rescue
Linux fundamental - Chap 16 System Rescue
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
 
Chap 18 net
Chap 18 netChap 18 net
Chap 18 net
 
Ras pioverview
Ras pioverviewRas pioverview
Ras pioverview
 
Linux pipe & redirection
Linux pipe & redirectionLinux pipe & redirection
Linux pipe & redirection
 
Linux network monitoring hands-on pratice
Linux network monitoring hands-on praticeLinux network monitoring hands-on pratice
Linux network monitoring hands-on pratice
 
Linux fundamentals
Linux fundamentalsLinux fundamentals
Linux fundamentals
 
Basics of-linux
Basics of-linuxBasics of-linux
Basics of-linux
 
Your first linux programs
Your first linux programsYour first linux programs
Your first linux programs
 
Power point (asking permission)
Power point (asking permission)Power point (asking permission)
Power point (asking permission)
 
Chap 19 web
Chap 19 webChap 19 web
Chap 19 web
 
Linux fundamental - Chap 05 filter
Linux fundamental - Chap 05 filterLinux fundamental - Chap 05 filter
Linux fundamental - Chap 05 filter
 
Linux fundamental - Chap 13 account management
Linux fundamental - Chap 13 account managementLinux fundamental - Chap 13 account management
Linux fundamental - Chap 13 account management
 
Linux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkgLinux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkg
 

Similaire à Unix - Filters/Editors

Similaire à Unix - Filters/Editors (20)

Group13
Group13Group13
Group13
 
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
 
COMMAND.pptx
COMMAND.pptxCOMMAND.pptx
COMMAND.pptx
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
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
 
Unit 8 text processing tools
Unit 8 text processing toolsUnit 8 text processing tools
Unit 8 text processing tools
 
Chapter 3 Using Unix Commands
Chapter 3 Using Unix CommandsChapter 3 Using Unix Commands
Chapter 3 Using Unix Commands
 
Linux Command.pptx
Linux Command.pptxLinux Command.pptx
Linux Command.pptx
 
Unix Tutorial
Unix TutorialUnix Tutorial
Unix Tutorial
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
 
Examples -partII
Examples -partIIExamples -partII
Examples -partII
 
Prabu linux
Prabu linuxPrabu linux
Prabu linux
 
Prabu linux
Prabu linuxPrabu linux
Prabu linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 

Dernier

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Dernier (20)

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

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