16.05.2015 Views

Working with the Unix OS

Working with the Unix OS

Working with the Unix OS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Introduction to <strong>Unix</strong><br />

1,$s/^/>>/<br />

1,$s/..$//<br />

/[tT]he/<br />

1,$s/[^a-zA-Z]//g<br />

1,$s/ */ /g<br />

1,$s/e.*e/+++/<br />

1,$s/^.\{10\}//<br />

1,$s/.\{5\}$//<br />

1,$s/\(.*\) \(.*\)/\2 \1/<br />

insert >> at beginning of each line<br />

delete <strong>the</strong> last 2 chars from each line<br />

look for <strong>the</strong> or The<br />

delete all non alphabetic characters<br />

change multiple blanks to single blanks<br />

change from first e to last e on a line<br />

delete first 10 chars from each line<br />

delete last 5 chars from each line<br />

switch to fields<br />

! Regular expression characters<br />

Notation Meaning Examples Matches<br />

. any character x.. x followed by any two characters<br />

^ begin of line ^wood line starting <strong>with</strong> wood<br />

$ end of line x$ line ending <strong>with</strong> x<br />

^$ line <strong>with</strong> no chars<br />

* zero or more x* zero or more x's<br />

occurrences of xx* one or more x's<br />

.x* zero or more chars<br />

[chars] any cha rs [tT] lower/uppercase t<br />

[a-z] lowercase letter<br />

[^chars] not chars [^0-9] any nonnumeric<br />

[^a-zA-Z] any nonalphabetic<br />

\{min,max\} at least min x\{1,5\} at least 1 and<br />

and at most max<br />

at most 5 x' s<br />

occurrences of [0-9]\{3,9\} anywhere from 3-9<br />

previous regular<br />

successive digits<br />

expression [0-9]\{3\} exactly 3 digits<br />

[0-9]\{3,\} at least 3 digits<br />

\(...\) store chars ^\(.\) 1st char on line<br />

matched between store in register 1<br />

paren<strong>the</strong>ses in ^\(.\)\1 1st and 2nd char on<br />

next register(1-9)<br />

line if <strong>the</strong>y're same<br />

Advanced Vi<br />

! Abbreviations<br />

:ab fit Faculty of Information Technology<br />

! Macros -set of macro chars { q, v, K^, ^A, ^ D, ^ E, ^X, ^Y }<br />

:map ^A :!cat $HOME/.vihelp^M<br />

! Search & Replace<br />

:g/man /s//person /gc<br />

:g/\(.*\) -\(.*\)/s//\2 -\1/gc<br />

! Customise options for ".exrc' file<br />

:set all<br />

options abbreviation default<br />

autoindent ai noai<br />

ignorecase (search) ic noic<br />

number nu nonu<br />

redraw<br />

noredraw<br />

showmatch ) } sm nosm<br />

wrapscan ws ws<br />

wrapmargin wm wm=0<br />

The UNIX Operating System<br />

! Advantages<br />

10

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!