SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

Unix & Linux File System in Operating System
Unix & Linux File System in Operating SystemUnix & Linux File System in Operating System
Unix & Linux File System in Operating SystemMeghaj Mallick
 
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 LinuxHenry Osborne
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memorysgpraju
 
Linux Directory Structure
Linux Directory StructureLinux Directory Structure
Linux Directory StructureKevin OBrien
 
Implementation of Pipe in Linux
Implementation of Pipe in LinuxImplementation of Pipe in Linux
Implementation of Pipe in LinuxTushar B Kute
 
Introduction to Linux
Introduction to Linux Introduction to Linux
Introduction to Linux Harish R
 
Linux standard file system
Linux standard file systemLinux standard file system
Linux standard file systemTaaanu01
 
VI editor in unix
VI editor in unix VI editor in unix
VI editor in unix Ahmed Fayyaz
 
file system in operating system
file system in operating systemfile system in operating system
file system in operating systemtittuajay
 
Linux command ppt
Linux command pptLinux command ppt
Linux command pptkalyanineve
 
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERS
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERSVTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERS
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERSvtunotesbysree
 
Unix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell ScriptUnix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell Scriptsbmguys
 
Presentation on samba server
Presentation on samba serverPresentation on samba server
Presentation on samba serverVeeral Bhateja
 
Vi editor Linux Editors
Vi editor Linux EditorsVi editor Linux Editors
Vi editor Linux EditorsTONO KURIAKOSE
 
Quick Guide with Linux Command Line
Quick Guide with Linux Command LineQuick Guide with Linux Command Line
Quick Guide with Linux Command LineAnuchit Chalothorn
 

Was ist angesagt? (20)

File management
File managementFile management
File management
 
Unix & Linux File System in Operating System
Unix & Linux File System in Operating SystemUnix & Linux File System in Operating System
Unix & Linux File System in Operating System
 
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
 
Filepermissions in linux
Filepermissions in linuxFilepermissions in linux
Filepermissions in linux
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memory
 
Linux Directory Structure
Linux Directory StructureLinux Directory Structure
Linux Directory Structure
 
Implementation of Pipe in Linux
Implementation of Pipe in LinuxImplementation of Pipe in Linux
Implementation of Pipe in Linux
 
Introduction to Linux
Introduction to Linux Introduction to Linux
Introduction to Linux
 
Linux standard file system
Linux standard file systemLinux standard file system
Linux standard file system
 
VI editor in unix
VI editor in unix VI editor in unix
VI editor in unix
 
file system in operating system
file system in operating systemfile system in operating system
file system in operating system
 
Linux command ppt
Linux command pptLinux command ppt
Linux command ppt
 
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERS
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERSVTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERS
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERS
 
Unix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell ScriptUnix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell Script
 
Presentation on samba server
Presentation on samba serverPresentation on samba server
Presentation on samba server
 
Shell programming
Shell programmingShell programming
Shell programming
 
Vi editor Linux Editors
Vi editor Linux EditorsVi editor Linux Editors
Vi editor Linux Editors
 
Quick Guide with Linux Command Line
Quick Guide with Linux Command LineQuick Guide with Linux Command Line
Quick Guide with Linux Command Line
 
Ext filesystem4
Ext filesystem4Ext filesystem4
Ext filesystem4
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
 

Andere mochten auch

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)
 

Andere mochten auch (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
 

Ähnlich wie Unix - Filters/Editors

Ähnlich wie 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
 

Kürzlich hochgeladen

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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
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
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Kürzlich hochgeladen (20)

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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

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