Tuesday, January 15, 2008

Unix file compression utilities

Unix file compression utilities: Creating a tape archive: tar -cf archive.tar myDirectories/ Listing the contents of an archive: tar -tf archive.tar Extracting all files from an archive: tar -xf archive.tar To extract just partial pieces from the archive, supply a file or directory name after the archive name. You can list as many as desiered here, separated by spaces. tar -xf archive.tar filename Compress: gzip archive.tar Decompress: gunzip archive.tar.gz Merging commands The "z" flag works with gzip, to either create a tar/gzipped archive: tar -czvf archive.tgz files/ Decompress a tar/gzipped archive: tar -xzvf archive.tgz

Friday, January 11, 2008

vi Commands

Undo Command

u undo the last command.

Screen Commands

CTL/F Pages forward one screen.

CTL/B Pages back one screen.

>> Indent right

<< Indent left

Cursor Positioning Commands

0 Moves cursor to beginning of current line.

$ Moves cursor to end of current line.

nG Moves cursor to beginning of line n. Default is last line of file.

:n Moves cursor to beginning of line n.

/pattern Moves cursor forward to next occurrence of pattern.

?pattern Moves cursor backward to next occurrence of pattern.

n Repeats last / or ? pattern search.

N Repeats last / or ? pattern search in opposite direction

:.= Print line number of current line

Text Insertion Commands

a Appends text after cursor.

A Appends text at the end of the line.

i Inserts text before cursor.

I Inserts text at the beginning of the line.

Text Deletion Commands

x Deletes current character.

dd Deletes current line.

d) Deletes the rest of the current sentence.

D, d$ Deletes from cursor to end of line.

P Puts back text from the previous delete.

Changing Commands

~ Changes case of current character.

J Joins current line with next line.

Cut and Paste Commands

yy Puts the current line in a buffer. Does not delete the line from its current position.

p Places the line in the buffer after the current position of the cursor.

Appending Files into Current File

:R filename Inserts the file filename where the cursor was.

Exiting vi

ZZ Exits vi and saves changes.

:wq Writes changes to current file and quits edit session.

:q! Quits edit session (no changes made).

Visual mode commands

v Start/stop visual mode Allows you to select a block of text

> shift the block right one shiftwidth

< shift the block left one shiftwidth

y yank ( copy ) the block ( paste with a p )

d delete the block

c change the block