Expressions Are Strings and Wildcards


graphics/grepa_icon.gif

When using the programs in this book, such as grep and vi , you provide a regular expression that the program evaluates . The command will search for the pattern you supply. The pattern could be as simple as a string or it could include wildcards. The wildcards used by many programs are called meta- characters .

graphics/grepawksed_icon.gif

Table 26-Expr shows a list of meta-characters and the program(s) to which they apply. Only the programs covered in this book ( awk, grep, sed , and vi ) are shown in Table 26-Expr. These meta-characters may be used with other programs, such as ed and egrep , as well, which are not covered in the book. Table 26-Expr describes the meta-characters and their use.

Table 26-Expr. Meta-Characters and Programs to Which They Apply

Meta-Character

awk

grep

sed

vi

Use

.

Yes

Yes

Yes

Yes

Match any single character.

*

Yes

Yes

Yes

Yes

Match any number of the single character that precedes * .

[ ... ]

Yes

Yes

Yes

Yes

Match any one of the characters in the set [ ... ] .

$

Yes

Yes

Yes

Yes

Matches the end of the line.

^

Yes

Yes

Yes

Yes

Matches the beginning of the line.

\

Yes

Yes

Yes

Yes

Escape the special character that follows \ .

\{ n,m \}

Yes

Yes

No

No

Match a range of occurrences of a single character between n and m .

+

Yes

No

No

No

Match one or more occurrences of the preceding regular expression.

?

Yes

No

No

No

Match zero or one occurrence of the preceding regular expression.

Yes

No

No

No

The preceding or following regular expression can be matched.

()

Yes

No

No

No

Groups regular expressions in a typical parenthesis fashion.

\{ \}

No

No

No

Yes

Match a word's beginning or end.

You may want to refer to this table when regular expressions are used for one of the commands in the table.

Modes and Notations

We're first going to cover some of the fundamentals of the operation of vi called modes, and then go over some of the notations used in the tables in this chapter.

A feature of vi that often confuses new users is that it has modes. When you are in command mode , everything you type is interpreted as a command. In command mode, you can specify such actions as the location to which you want the cursor to move. When you are in input mode, everything you type is information to be added to the file. Command mode is the default when you start vi . You can move into command mode from input mode at any time by pressing the escape key. You move into insert mode from command mode by typing one of the input mode commands covered shortly.

vi commands don't really have a standard form. For this reason, I cover common notations. Table 26-Introduction summarizes modes and commands in vi :

Table 26-Introduction. Modes and Notations in vi

Mode or Notation

Description

Command Mode

You are issuing commands such as moving the cursor or deleting text, rather than inserting or changing text when in command mode. You can switch to insert mode by issuing an insert mode command such as i for insert or a for add text.

Insert Mode

You are in insert mode when changing or inserting more than one character of text. You can switch to command mode by pressing the escape key.

: ( colon commands)

Commands that start with a : are completed by pressing the return key.

control ( ^ ) commands

When a command uses the control ( ^ ) key, you press and hold down the control key and then press the next key that is part of the command. For instance, ^g means press and hold control and then g to get the status on the file you are editing.

file for the name of a file

Many commands require you to specify the name of a file. For instance, in the command vi file, you would substitute the name of the file you wish to edit for file.

char for the name of a character

Many commands require you to specify a single character. For instance, in the command f char, you would substitute the character you wish to search for in place of char .

cursor_command for a cursor movement command

Many commands require you to specify a cursor command to execute. For instance, in the command d cursor_command, you would substitute for cursor_command the command you wish to execute.

string for a character string

Many commands require you to specify a character string. For instance, in the command / string, you would substitute for string the character string for which you wish to search.

Starting a vi Session

Let's jump right in and edit a file. For most of the examples in this chapter, I perform various vi commands and capture the results in an X Window. The best way to learn any topic is by example. I not only provide many examples, but I also capture each example in an X Window so that you can see the results of each command. From the command line, we type vi and the name of the file we wish to edit, in this case wisdom :

 $  vi wisdom  

We are then editing the file wisdom as shown in Figure 26-1. wisdom contains a passage from Tao Te Ching or "Book of the Way." We use this file throughout this chapter.

Figure 26-1. Editing the File wisdom

graphics/26fig01.gif

The bottom line in Figure 26-1 is the message line in vi . After invoking vi, the message line indicates the name of the file, the number of lines, and the number of characters in the file. Different messages appear on the message line, depending on the command you issue, as we see in upcoming examples. If a tilde appears on any lines in the file, as it does in the two lines above the message line in wisdom , it means that not enough lines exist to fill up the screen. The cursor is the dark box that appears at line 1 in Figure 26-1.

We can specify several file names , and after saving the first file move on to the second file by entering :n , and continue going through the list of files in this way. Or we can specify a file and position the cursor on the last line in the file. The default is for the cursor to appear over the first character in the file, as shown in Figure 26-1.

Table 26-1 shows some of the ways in which we can start a vi session:

Table 26-1. Starting a vi Session

Command

Description

vi file

Edit file.

vi -r file

Edit last saved version of file after a crash.

vi -R file

Edit file in read-only mode.

vi + n file

Edit file and place cursor at line n .

vi + file

Edit file and place cursor on last line.

vi file1 file2 file3 ...

Edit file1 through file3, and after saving changes in file1, you can move to file2 by entering :n .

vi +/ string file

Edit file and place cursor at the beginning of the line containing string .

Figure 26-2 shows editing wisdom and placing the cursor at line 5 with the command vi +5 wisdom :

Figure 26-2. Editing the File wisdom and Placing Cursor at Line 5 with vi +5 wisdom

graphics/26fig02.gif

Figure 26-3 shows editing wisdom and placing the cursor at the last line of the file with the command vi + wisdom .

Figure 26-3. Editing the File wisdom and Placing Cursor at Last Line with vi + wisdom

graphics/26fig03.gif

Figure 26-4 shows editing wisdom and placing the cursor at the line containing task with vi +/task wisdom .

Figure 26-4. Editing the File wisdom and Placing Cursor at Line Containing task with vi +/task wisdom

graphics/26fig04.gif

Cursor Control Commands

A key skill to develop in vi is getting the cursor to the desired position. You do this in command mode . You have a variety of ways to move the cursor around the screen. Table 26-2 summarizes some of the more commonly used cursor movements:

Table 26-2. Cursor Control Commands In vi

Command

Cursor Movement

h or ^h

Move left one character.

j or ^j or ^n

Move down one line.

k or ^p

Move up one line.

l or space

Move right one character.

G

Go to the last line of the file.

n G

Go to line number n .

G$

Go to the last character in the file.

1G

Go to the first line in the file.

w

Go to the beginning of the next word.

W

Go to the beginning of next word, ignore punctuation.

b

Go to the beginning of the previous word.

B

Go to the start of previous word, ignore punctuation.

L

Go to the last line of the screen.

M

Go to the middle line of the screen.

H

Go to the first line of the screen.

e

Move to the end of the next word.

E

Move to the end of the next word, ignore punctuation.

(

Go to the beginning of the sentence .

)

Go to the end of the sentence.

{

Go to the beginning of the paragraph.

}

Go to the beginning of the next paragraph.

0 or

Go to the first column in the current line.

n

Go to column n in the current line.

^ (caret)

Go to the first non-blank character in the current line.

$

Go to the last character in the current line.

+ or return

Go to the first character in the next line.

-

Go to the first non-blank character in the previous line.

I know that the fact that you have to remember these commands in order to get the cursor to the desired position may seem a little strange at first, but this is the way vi works. Let's use wisdom to show how some of these cursor movements work. Figures 26-5 and 26-6 show some cursor movements. Like all of the upcoming figures, Figures 26-5 and 26-6 show wisdom appears before a command is entered on the left and the result after the command is entered on the right. The command issued appears in the middle. Some of the commands in upcoming figures use the enter and escape keys.

Figure 26-5. Examples of Cursor Movement in vi ( h, j, k , and l )

graphics/26fig05.jpg

Figure 26-6. Examples of Cursor Movement in vi ( G, w, b , and e )

graphics/26fig06.jpg

Adding Text in vi

Now that we know how to move around the cursor, let's do something with it. You need to first learn about cursor movement, because the commands for adding text take place relative to the position of the cursor. Table 26-3 summarizes some commands for adding text:

Table 26-3. Adding Text In vi

Command

Insertion Action

a

Append new text after the cursor.

A

Append new text after the end of the current line.

i

Insert new text before the cursor.

I

Insert new text before the beginning of the current line.

o

Open a line below the current line and insert.

O

Open a line above the current line and insert.

:r file

Read file and insert after the current line.

: n r file

Read file and insert after line n .

escape

Get back to command mode.

^v char

Ignore special meaning of char when inserting. This is for inserting special characters.

Let's now look at some examples of adding text into wisdom in Figure 26-7:

Figure 26-7. Examples of Adding Text in vi

graphics/26fig07.jpg

Deleting Text in vi

We also need to learn about cursor movement before learning how to delete text, because the commands for deleting text take place relative to the position of the cursor. Table 26-4 summarizes some commands for deleting text:

Table 26-4. Deleting Text In vi

Command

Deletion Action

x

Delete the character at the cursor. You can also put a number in front of x to specify the number of characters to delete.

n x

Delete n characters beginning with the current.

X

Delete the previous character. You can also put a number in front of X to specify the number of previous characters to delete.

n X

Delete previous n characters.

dw

Delete to the beginning of the next word.

n dw

Delete the next n words beginning with the current.

dG

Delete lines to the end of the file.

dd

Delete the entire line.

n dd

Delete n lines beginning with the current.

db

Delete the previous word.

n db

Delete the previous n words beginning with the current.

: n , m d

Deletes lines n through m .

D or d$

Delete from the cursor to the end of the line.

d cursor_command

Delete text to the cursor_command . dG would delete from the current line to the end of the file.

^h or backspace

While inserting, delete the previous character.

^w

While inserting, delete the previous word.

Let's now look at some examples of deleting text from wisdom in Figures 26-8 and 26-9:

Figure 26-8. Examples of Deleting Text in vi ( x, X, dw , and dG )

graphics/26fig08.jpg

Figure 26-9. Examples of Deleting Text in vi ( dd and db )

graphics/26fig09.gif

Changing Text in vi

Okay, you've added text and deleted text, and now you want to change text. vi isn't so bad so far, is it? Table 26-5 summarizes some commands for changing text:

Table 26-5. Changing Text In vi

Command

(Preceding these commands with a number repeats the commands any number of times.)

Replacement Action

r char

Replace the current character with char .

R text escape

Replace the current characters with text until escape is entered.

s text escape

Substitute text for the current character.

S or cc text escape

Substitute text for the entire line.

cw text escape

Change the current word to text .

C text escape

Change the rest of the current line to text.

cG escape

Change to the end of the file.

c cursor_cmd text escape

Change to text from the current position to cursor_cmd.

Let's now look at some examples of replacing text from wisdom in Figures 26-10 and 26-11:

Figure 26-10. Examples of Changing Text in vi ( r, R, cw , and cG )

graphics/26fig10.jpg

Figure 26-11. Example of Changing Text in vi with cc

graphics/26fig11.gif

Search and Replace in vi

You have a lot of search and replace functionality in vi . Table 26-6 summarizes some of the more common search-and-replace functionality in vi :

Table 26-6. Search And Replace In vi

Command

Search and Replace Action

/ text

Search for text going forward into the file.

? text

Search for text going backward into the file.

n

Repeat the search in the same direction as the original search.

N

Repeat the search in the opposite direction as the original search.

f text

Search for text going forward in the current line.

F text

Search for text going backward in the current line.

t text

Search for text going forward in the current line and stop at the character before text.

T text

Search for text going backward in the current line to character after text.

:set ic

Ignore case when searching.

:set noic

Make searching case-sensitive.

:s/ oldtext / newtext /

Substitute newtext for oldtext .

: m , n s/ oldtext / newtext /

Substitute newtext for oldtext in lines m through n .

&

Repeat the last :s command.

:g/ text1 /s/ text2 / text3

Find line containing text1, replace text2 with text3.

:g/ text / command

Run command on all lines that contain text .

:v/ text / command

Run command on all lines that do not contain text .

Let's now look at some examples of searching and replacing text in wisdom in Figure 26-12:

Figure 26-12. Examples of Search and Replace in vi

graphics/26fig12.jpg

You can perform advanced searches with :g and :v . You can find and display all the lines in a file containing while with the following command:

  :g/while/p  

The /p in this command line is the print command used with the ex editor. You could find all the lines in the file that contain while and delete those lines with the following command:

  :g/while/d  

You can also specify the specific line numbers for which you want the search to take place. The following command finds all the lines between 10 and 20 that contain while and prints the line number on which they appear:

  :10,20g/while/nu  

:g runs a command on the lines that contain the text for which we are searching, and :v runs a command on the lines that do not contain the specified text. The following three commands act on the lines that do not contain while , in the same way that the previous three act on the lines that do contain while :

  :v/while/p   :v/while/d   :10,20v/while/nu  

The first command prints lines that do not contain while . The second command deletes the lines on which while does not appear. The third command prints the line number between 10 and 20 on which while does not appear.

Copying Text in vi

You can copy text in vi . Some commands for copying are shown in Table 26-7:

Table 26-7. Copying In vi

Command

Copy Action

yy

Yank the current line.

nyy

Yank n lines.

p (lower case)

Put the yanked text after the cursor.

p (upper case)

Put the yanked text before the cursor.

"(a-z)n yy

Copy n lines into the buffer named in parentheses. Omit n for the current line.

"(a-z)n dd

Delete n lines into the buffer named in parentheses. Omit n for the current line.

"(a-z) p

Put lines named in the buffer in parentheses after current line.

"(a-z) P

Put lines named in the buffer in parentheses before the current line.

Let's now look at some examples of copying text in wisdom in Figure 26-13:

Figure 26-13. Copying in vi

graphics/26fig13.jpg

Undo and Repeat in vi

You can easily undo and repeat changes in vi with the commands shown in Table 26-8:

Table 26-8. Unso In vi

Command

Undo Action

u

Undo the last change.

U

Undo all changes to the current line.

. (period)

Repeat the last change.

, (comma)

Repeat, in reverse direction, last f, F, t , or T search command.

; (semi-colon)

Repeat last f, F, t, or T search command.

" n p

Retrieve the last n th delete (a limited number of deletes are in the buffer, usually nine).

n

Repeat last / or ? search command.

N

Repeat, in reverse direction, last / or ? search command.

Save Text and Exit vi

You have a number of different ways to save files and exit vi , some of which are summarized in Table 26-9:

Table 26-9. Saving Text and Exiting vi

Command

Save and/or Quit Action

:w

Save the file but don't exit vi .

:w file

Save changes in file but don't quit vi .

:wq or ZZ or :x

Save the file and quit vi .

:q!

Quit vi without saving the file.

:e!

Re-edit the file, discarding changes since the last write.

Options in vi

There are many options that you can set and unset in vi . To set an option, you type :set option . To unset an option, you type :set no option . Table 26-10 summarizes some of the more commonly used options:

Table 26-10. Options In vi

Option

Action

:set all

Print all options.

:set no option

Turn off option .

:set nu

Prefix lines with line number.

:set showmode

Show whether input or replace mode.

:set noic

Ignore case when searching.

:set list

Show tabs (^l) and end of line ($).

:set ts=8

Set tab stops for text input.

:set window= n

Set number of lines in a text window to n.

Let's now prefix the lines with line numbers and show the input or replace mode in Figure 26-14:

Figure 26-14. Options in vi

graphics/26fig14.jpg

Many additional options are available beyond those in Table 26-10. The following is a list of options produced on a UNIX system from the :set all command. You should issue this command when in vi to see the options available to you:

 :  set all  noautoindent autoprint noautowrite nobeautify directory=/var/tmp nodoubleescape noedcompatible noerrorbells noexrc flash hardtabs=8 noignorecase keyboardedit nokeyboardedit! nolisp nolist magic mesg nomodelines nonumber nonovice nooptimize paragraphs=IPLPPPQPP LIpplpipnpbp prompt noreadonly redraw remap report=5 scroll=11 sections=NHSHH HUuhsh+c shell=/sbin/sh shiftwidth=8 noshowmatch noshowmode noslowopen tabstop=8 taglength=0 tags=tags /usr/lib/tags tagstack term=hp noterse timeout timeoutlen=500 ttytype=hp warn window=23 wrapscan wrapmargin=0 nowriteany noshowmatch noshowmode 

Many of the options are preceded by a "no," indicating that the option is not set. You may want to list your options with :set all and then experiment with the options of interest to you to see the effect they will have on your vi session.

Status in vi

You can obtain a lot of useful status information with some simple commands in vi . You can display the current line number, number of lines in the file, file name, and other status information with the commands shown in Table 26-11:

Table 26-11. Status In vi

Option

Action

:.=

Print the current line number.

:=

Print the number of lines in the file.

^g

Show the file name, current line number, total lines in the file, and percent of file location.

:l

Use the letter "l" to display various special characters such as tab and newline.

Section Positioning and Placing Marks in Text

You can define sections of text to which you can move as well as mark text with characters and move to those marks. Table 26-12 summarizes positioning and marking in vi :

Table 26-12. Positioning and Marking In vi

Option

Action

{

Insert { in first column to define section.

[[

Go back to beginning of section.

]]

Forward to beginning of next section.

m (a-z)

Mark current position with a letter such as mz for mark z .

' (a-z)

Move cursor to specified mark such as 'z for move to z .

Joining Lines in vi

You can join one or more lines in vi using the commands shown in Table 26-13:

Table 26-13. Joining Lines In vi

Option

Action

J

Join the next line to the end of the current line.

n J

Join the next n lines.

Cursor Placement and Adjusting the Screen

You can place the cursor anywhere in your file and adjust the screen in a variety of ways using the commands shown in Table 26-14:

Table 26-14. Cursor Placement and Adjusting the Screen In vi

Option

Action

H

Move cursor to top line of the screen.

n H

Move cursor to n line from the top of the screen.

M

Move cursor to the middle of the screen.

L

Move cursor to the bottom line of the screen.

n L

Move cursor to line n from the bottom of the screen.

^e (control-e)

Move screen up one line.

^y

Move screen down one line.

^u

Move screen up one-half page.

^d

Move screen down one-half page.

^b

Move screen up one page.

^f

Move screen down one page.

^l (letter l)

Redraw screen.

z - return

Make current line the top of screen.

n z - return

Make n line the top of screen.

z.

Make current line the middle line.

n z.

Make line n the middle line on screen.

z-

Make current line the bottom line.

n z-

Make line n the bottom line on screen.

Shell Escape Commands

You can run a UNIX command without exiting vi by using shell escape commands. You could do something as simple as start a sub-shell with the :sh command. You could also run a command outside the file you are editing without exiting vi . Table 26-15 describes shell escape commands:

Table 26-15. Shell Escape Commands In vi

Option

Action

:! command

Execute shell command command such as :! ls .

:!!

Execute last shell command.

:r! command

Read and insert output from command, such as :r! ls to run ls and read contents.

:w ! command

Send currently edited file to command as standard input and execute command, such as :w ! grep all .

:cd directory

Change the current working directory to directory.

:sh

Start a sub-shell and use ^d (control-d) to return to vi .

:so file

Read and execute commands in the shell program file.

graphics/grepa_icon.gif

An example of using :w would be to send the file wisdom as a standard input to grep, looking for all lines that contain all , as in the following example:

  :w ! grep all  Think of the small as by a series of small acts. 

You can issue the :so command to read and execute the commands in a file. Issuing the following command when in vi would run the commands in the file file_with_commands :

  :so file_with_commands  

This file contains the following two commands:

  :set nu   :g/all/p  

When we issue the earlier :so command, line numbers are shown with the :set nu command and the following lines containing all are printed:

 Think of the small as by a series of small acts. 

Macros and Abbreviations

You are not limited to issuing individual vi commands. You can define strings of vi commands and define a key corresponding to this string that you can recall. When defining the keys for your macros, you can't use the following: K V g q v * = and function keys. There are also control keys you can't use, so stay away from control keys in general. Table 26-16 shows macros and abbreviations.

Table 26-16. Macros and Abbreviations In vi

Option

Action

:map key command_seq

Define key to run command_seq, such as :map e ea to append text whenever you use e to move to the end of a word.

:map

Display all defined macros on the status line.

:umap key

Remove the macro for key.

:ab string1 string2

Define an abbreviation such that when string1 is inserted, replace it with string2. When inserting text type string1, press escape key and string2 will be inserted.

:ab

Display all abbreviations.

:cd directory

Change the current working directory to directory.

:una string

Unabbreviate string.

 

Avoid control keys, symbols, and don't use characters: K V g q v * = and function keys.

An example of using the map command would be to automatically add text when you move to the end, as shown with the following map command:

  :map e ea  

This command maps e to ea. When you go to the end of the next word with e, you are also placed in insert mode with a so that you can append new text immediately after the end of the word.

You can also abbreviate long sequences with ab. For instance, you could abbreviate system administration with sa with the following command:

  :ab sa system administration  

Now, whenever you insert text, type sa and then press the escape key to complete the insert; the string system administration appears. sa is an abbreviation for system administration.

Indenting Text

You can indent text in a variety of different ways. Table 26-17 shows some of the more commonly used indenting commands:

Table 26-17. Indenting Text In vi

Option

Action

^i (control i) or tab

While inserting text, insert on shift width. Shift width can be defined.

:set ai

Turn on auto-indentation.

:set sw= n

Set shift width to n characters.

n <<

Shift n lines left by one shift width.

n >>

Shift n lines right by one shift width. For example, 3>> shifts the next three lines right by one shift width.

Before you adjust the shift width, you may want to issue :set all in order to see the current number of characters to which the shift width is set. It is usually eight characters by default. To set the shift width to 16 characters, issue the following command:

  :set sw=16  

You can then shift over the next three lines to the right by 16 characters each, with the following command:

  3>>  

The next three lines are then shifted right by 16 characters.

Shell Filters

You can send information from the file you are editing to a command and then replace the original text with the output of the command. Table 26-18 shows a shell filter:

Table 26-18. Shell Filters In vi

Option

Action

! cursor_command command

Send text from the current position to that described by cursor_command to the shell command. For example, use !} grep admin to take text from the current position to the end of the paragraph, run this text through grep looking for the word admin , and replace existing text with the output of grep .

Pattern Matching

Pattern matching allows you to find patterns within the file you are editing. You can then perform functions such as changing what you have found in some way. Table 26-19 shows some of the most common pattern-matching commands:

Table 26-19. Pattern Matching in vi

Option

Action

^ (caret)

Match the beginning of the line.

To search for Think at only the beginning of the line, you would use:

/^Think

You can use this in combination with $ , which matches to the end of the line, to delete all blank lines with:

:g/^$/d .

$

Match end of line.

To match last. only when it is followed by a newline character, you would use:

/last.$

.

Match any single character.

\<

Match beginning of word.

\>

Match end of word.

[ string ]

Match any single character in string .

To find mp, mP, Mp , or MP , use:

/[mM][pP]

Change all occurrences of input or Input to INPUT with:

:%s/[Ii]nput/INPUT/g

[ ^string ]

Match any character not in string.

[ a-p ]

Match any character between a and p.

*

Match zero or more occurrences of previous character in expression.

\

Escape meaning of next character. To search for [ , use the following:

/\[

\\

Escape the \ character.

You may find pattern matching a little confusing when you first start to use it, so I'll go through several simple examples to get you started. Keep in mind that many of the pattern-matching techniques described here also work outside vi in your shell.

Matching a Set

We'll begin with the square bracket operator . To match any of the single characters m, f, or p , you would use the following:

  /[mfp]  

A common pattern to match would be a word with the first letter in the word, either uppercase or lowercase. To match input or Input , you would use the following:

  /[Ii]nput  

After you match either Input or input , you could then change it to INPUT with the following command:

  :%s/[Ii]nput/INPUT/g  

You can use sequences of expressions to search for more than one character, as shown in the following example:

  /[mM][pP]  

This sequence will match mp, mP, Mp , or MP . You are, in effect, searching for any of the four two-character strings.

Matching a Range

You can also use the square bracket operator to match single characters within a range. To find an occurrence of any digit in a file, you could use either of the two following square bracket searches:

  /[0123456789]  

or

  /[0-9]  

The hyphen denotes a range within the square bracket. To find any character, either uppercase or lowercase, you could use the following:

  /[a-zA-Z]  

To search for characters that normally have a special meaning, such as [ , you can ignore, or escape, the special meaning by preceding the special character with a \ (backslash). To search for [ in vi , for instance, you would use the following sequence:

  /\[  

This search finds the first occurrence of [ .

Beginning and End of Line Search

You can specify that you wish your pattern match to take place at only the beginning or end of a line. To specify a beginning of the line pattern match, use the ^ (caret) preceding your desired pattern, as shown in the following example:

  /^Think  

This matches Think only when it appears at the beginning of a line.

To specify an end-of-the-line pattern match, use a $ (dollar sign) following your desired pattern, as shown in the following example:

  /last.$  

This matches last. only when it is followed by a newline. Manual Pages for Commands Used in Chapter 24Manual Pages for Commands Used in Chapter 24



HP-UX 11i Systems Administration Handbook and Toolkit
HP-UX 11i Systems Administration Handbook and Toolkit (2nd Edition)
ISBN: 0131018833
EAN: 2147483647
Year: 2003
Pages: 301

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net