Professional Documents
Culture Documents
UNIX BASICS
UNIX History
UNIX Architecture
Basic Unix Commands
File System
File Commands
Vi Editor
Intro to AWK
UNIX History
UNIX was developed at AT&T Bell
Laboratories by Ken Thompson and
Denis Ritchie with the intention of
creating a portable operating system.
It was finally written in C, and now
runs on all machines from notebook
to mainframes.
Unix
UNIX Architecture
UNIX Architecture is a Computer Operating
System Architecture that embodies the Unix
philosophy.
UNIX Architecture
UNIX Commands
UNIX Commands
File Permissions
File Commands
File Commands
file.htm
File Commands
File Commands
File Commands
File Commands
File Commands
Sort Command
vi Editor
Command mode
Input mode
Inserting Text
No RETURN
Finishing a vi Session
:wq
quit
:q!
No RETURN
required!
go to line
number
Go to first line
Move to end of line
Move to beginning of line
Type RETURN!
/text
/func
?text
?foo
searchforfoobackward
Deletion
:i,jd
Example
Delete lines i to j
:23,29d
Delete lines 23 to 29
:.,$d
Moving Text
File-related Commands
:w file writes vi contents to new file
:w >> file
appends to file
Text Substitution
:1,$s/old/new/g
:1,$s/Hat/Cat/g
replace every
occurrence of old by
new.
:i,js/old/new/g
replace every
occurrence of old by
new between lines i and j
:2,200s/darshan/DARSHAN/g
:1,.s/fc/function/g
current
from line 1 to
Customizing VI
:set ai(automatic indentation).
:set ic Ignore case when searching for
a patterns.
:set nomagic Searches a pattern like g*
:set nu will set the line number
/string :- search a perticular pattern with
in a file
AWK
It is an excellent filter and report writer. Many UNIX utilities generates rows and
Some
important
AWK
commands
which
can
columns
of information.
AWK is an
excellent
tool for processing
these
rows and
help us
ineasier
Daily
activities.
colu`mns,
and is
to use
AWK than most conventional programming
#!/bin/ksh -x
Sample/Simple script
vi example.ksh
Now in insert mode (i)
#!/bin/ksh
clear
echo "Good morning, world."
Esc:wq and execute
./example.ksh
To run a script
2clear
3echo "Good morning, world.
4cp abc.txt bcd.txt
5mv abc.txt bcd.txt
grep I who abc.txt >> mno.txt | cat
mno.txt
.
..esc:/ clear :1,$s/Good/Bad/ :set nu
QUESTIONS?