Professional Documents
Culture Documents
Introduction - UNIX
General Commands
File/Directory Manipulation
Data Manipulation
Networking/Communications
Miscellaneous
vi Editor
Unix Evolution
Multitasking capability
Multi-user capability
Portability
UNIX tools :
Integral
Non -Integral
UNIX Communications
Applications libraries
UNIX Organization
To logout : exit
$passwd [ENTER]
General
cat files : Concatenate file(s); you can use cat to display the
contents of a file (this is not advisable if the file is a binary file).
grep "pattern" files : Display all lines in the files that match a pattern.
$ chmod +x homefiles
chmod
The grep utility searches text files for a pattern and prints
all lines that contain that -pattern
grep [-bchilnsvw] limited-regular-expression [filename]
wc utility
The wc utility reads one or more input files and, by default,
writes the number of newline characters, words and bytes
contained in each input file to the standard output.
wc [ -c| -m| -C] [-lw] [file]
-c Count bytes.
-m and -C Count characters.
-l Count lines.
-w Count words delimited by white space
characters or new line characters.
Example :
#wc -clw xxx.txt
More, Page
Examples :
more /etc/passwd
more /etc/inittab
head & tail
Example :
$Head -10 phone.txt
$tail +5 phone.txt
cmp ,diff ,EOF, BOF
Examples :
diff phone.txt phone.old
diff phone.txt phone.old
Printing files
kill -9 111
tar
The VI editor is a screen-based editor used by many Unix users. The VI editor
uses the full screen, so it needs to know what kind of terminal you have. When
you log in, wiliki should ask you what terminal you have. The prompt looks like
this: TERM = (vt100)
The vi editor lets a user create new files or edit existing files. The command to
start the vi editor is vi, followed by the filename.
Vi Editor
vi <filename> or < no filename >( it will ask filename
while saving the file.)
Useful vi commands
i : insert mode.
<esc> : leave insert mode and go into command
mode.
a : append characters to the end of the line.
o : open a line below your cursor.
O : open a line above.
<shift>g : go to the bottom of the file.
r : replace the letter that you are on with the one you
type next.
Vi Editor
A stream editor.
Syntax
sed [ -n ] Script [ File ... ]
sed [ -n ] [ -e Script ] ... [ -f ScriptFile ] ... [ File ... ]
Description
The sed command modifies lines from the specified File parameter according
to an edit script and writes them to standard output. The sed command
includes many features for selecting lines to be modified and making
changes only to the selected lines.
The sed command uses two work spaces for holding the line being modified:
the pattern space, where the selected line is held; and the hold space, where
a line can be stored temporarily.
awk Command
Finds lines in files that match patterns and then performs specified actions on them.
Syntax
awk [ -F Ere ] [ -v Assignment ] ... { -f ProgramFile | 'Program' } [ [ File ... | Assignment ... ] ] ...
Description
The awk command utilizes a set of user-supplied instructions to compare a set of files, one line
at a time, to extended regular expressions supplied by the user. Then actions are performed
upon any line that matches the extended regular expressions. The maximum record size that
awk processes is 10KB.
The pattern searching of the awk command is more general than that of the grep command,
and it allows the user to perform multiple actions on input text lines. The awk command
programming language requires no compiling, and allows the user to use variables, numeric
functions, string functions, and logical operators.