Edlin: r (replace)

Searches a block of consecutive lines for a string of one or more characters that you specify, and replaces each occurrence of that string with another string that you specify.

Syntax

[line1][,line2][?]r[string1][CTRL+Z string2]

Parameters

line1 : Specifies the first line in which you want to replace the string specified in string1.

line2 : Specifies the last line in which you want to replace the string specified in string1.

? : Sends a confirmation message before Edlin.exe replaces an occurrence of the string specified in string1.

string1 : Specifies the string that you want to replace.

CTRL+Z : Separates the string1 and string2 values. The only valid value for this parameter is the end-of-file character (CTRL+Z), which appears as ^Z.

string2 : Specifies the new string that is to replace each occurrence of the string specified in string1.

Remarks

Windows XP does not use this command. It is accepted only for compatibility with MS-DOS files. 

This tool is not available on Windows XP 64-Bit Edition. 

The new current line is the last line in which Edlin.exe replaces string1.

Command-line spacing

Do not insert a space between r and any subsequent parameters on the command line.

Omitting parameters

If you omit line1, Edlin.exe begins the search on the line after the current line. If you omit line2, Edlin.exe stops the search at the end of the file or at the end of the text that is currently in memory.

If you omit string1, Edlin.exe uses the most recently used of the following two values: the value that you specified for string1 the last time you used r or the value that you specified for string the last time you used s during this session. If you omit string1 and you have not used the r or s subcommands during the current editing session, the r subcommand stops immediately.

If you omit string2, Edlin.exe uses the value you specified the last time you used the r command during this session. If you omit string2 and you have not used the r command during the current session, Edlin.exe deletes all occurrences of the string that specified in string1.

Using CTRL+Z

You must separate string1 and string2 values by using CTRL+Z. If you omit string1, you still need to press CTRL+Z to mark the beginning of string2. When you press CTRL+Z, the following characters appear:

^Z

Using the question mark (?) parameter

If you include the ? parameter in your command, Edlin.exe displays the line containing the first occurrence of the string specified for string1 and prompts you by displaying the following confirmation message:

O.K.? _

If you press Y or ENTER, Edlin.exe replaces this occurrence of string1 with the value for string2 and searches for the next occurrence. If you press N, Edlin.exe does not replace this occurrence of the value for string1 and searches for the next occurrence.

If you do not use the ? parameter to confirm replacements as they are made, Edlin.exe replaces all of the occurrences of string1 at once, and then displays each line that contains a replacement. If a line contains two or more replacements, Edlin.exe displays the line once for each replacement.

Examples

To replace each occurrence of "mine" with the word "ours" within the first 20 lines of the edited file in memory and receive a confirmation message, type, but do not press ENTER:

1,20?rmineCTRL+Zours 

CTRL+Z appears on the screen as ^Z. The command appears on the screen as follows:

1,20?rmine^Zours

In this example, the following file is in memory and ready to edit. When you use the l (list) subcommand at the * prompt, Edlin.exe displays the contents of the file.

1: Dear Mr. Muth: 
2: 
3: Congratulations on your promotion 
4: to the position of Senior Chemical 
5: Engineer. I continue to be most 
6: impressed with your fine work. 
7: 
8: I think you will enjoy working with 
9: Mr. Lang on the new project. Please 
10: let me know if there is anything I 
11: can do to assist you. 
12: 
13: Sincerely, 
14: 
15: Clay Martin, President 
16: Contoso, Ltd
17: "A World Leader in Technology" 

To replace all occurrences of the word "I" with the words "yours truly" in lines 5 through 10 without receiving a confirmation message, type:

5,10rICTRL+Zyours truly

CTRL+Z appears on the screen as ^Z. The command appears on the screen as follows:

5,10rI^Zyours truly

Because you did not include the ? parameter, Edlin.exe replaces the three occurrences of "I" without displaying the confirmation message. When Edlin.exe finishes carrying out the command, it displays the following lines, which are changed as a result of the three replacements:

5: Engineer. yours truly continue to be most 
8: yours truly think you will enjoy working with 
10: let me know if there is anything yours truly 

In the previous example, two unintended replacements occurred in lines 5 and 8. To avoid this type of change, add the ? parameter to the command. The completed command should appear on screen as follows:

5,10?rI^Zyours truly

Edlin.exe prompts you by displaying the confirmation message for each occurrence of the string specified in string1 and carries out only confirmed replacements, as the following example shows:

5: Engineer. yours truly continue to be most 
O.K.? n 
8: yours truly think you will enjoy working with 
O.K.? n 
10: let me know if there is anything yours truly 
O.K.? y 

When you use the ? parameter, Edlin.exe does not automatically display the lines that Edlin.exe changes as a result of the confirmed replacements. If you type the l (list) subcommand at the * prompt, Edlin.exe displays the edited file that is in memory, as follows:

1: Dear Mr. Muth: 
2: 
3: Congratulations on your promotion 
4: to the position of Senior Chemical 
5: Engineer. I continue to be most 
6: impressed with your hard work. 
7: 
8: I think you will enjoy working with 
9: Mr. Lang on the new project. Please 
10: let me know if there is anything yours truly 
11: can do to assist you. 
12: 
13: Sincerely, 
14: 
15: Clay Martin, President 
16: Contoso, Ltd
17: "A World Leader in Technology" 

Formatting legend

FormatMeaning

Italic

Information that the user must supply

Bold

Elements that the user must type exactly as shown

Ellipsis (...)

Parameter that can be repeated several times in a command line

Between brackets ([])

Optional items

Between braces ({}); choices separated by pipe (|). Example: {even|odd}

Set of choices from which the user must choose only one

Courier font

Code or program output

Edlin

Edlin subcommands

Command-line reference A-Z



© 2015 Microsoft Corporation. All rights reserved. Contact Us |Terms of Use |Trademarks |Privacy & Cookies