Edlin command

Updated: 11/12/2023 by Computer Hope
edlin command

The edlin command is an earlier version of the MS-DOS edit command. While not as easy or refined as the MS-DOS text editor, edlin does allow the user to crudely edit files.

Alternative method to create a file

An alternative option is to use the following command to create a file (not edit).

copy con <name of file>

Once you have entered the command above, a file with specified name is created.

After typing all the lines you want to be in the file, press and hold Ctrl+Z. Pressing these keys creates ^Z at the prompt. Once seen, press Enter and one file should be copied.

Availability

Edlin is an external command that is available for the following Microsoft operating systems. In MS-DOS 4.x and earlier edlin.com was used as the external file. In MS-DOS 5 and versions of Windows that supported the command, edlin.exe was used as the external file.

Edlin syntax

EDLIN [drive:][path][file name]
[RANGE] L Displays a range of lines. If no range is specified, L lists the first 23 lines of the file you are editing.
[RANGE] P Displays listing of range of lines. If no range is specified P displays the complete file. This option is different from L, in that P changes the current line to be the last line.
[RANGE] S [STRING] Searches the current file open for a certain string.
[RANGE], [LINE], [NUMBER] C Copies the specified range to the specified line. The number specifies how many copies to do.
[RANGE] D Deletes a certain range of lines.
[LINE] I Inserts new line at the beginning of line specified.
To save the line instead and exit out of the insert menu press <Ctrl> + Z + <Enter>
Press <Ctrl> + <C> to exit out of the insertion.
[RANGE], [LINE] M Moves a certain range to the specified line.
[LINE] Allows the editing of the specified line.
[RANGE] R [STRING1] [STRING2] Searches the specified range for the first specified string if the string is found replaces the string with the second specified string.
[NUMBER] A Reads the number of lines into memory.
[LINE] T [DRIVE:] [\PATH] [FILE] Merges the specified file into the current document at the specified line.
[NUMBER] W Writes the specified number of lines onto disk.
Q Quits edlin without saving changes.
E Quits edlin after saving changes.

Windows 2000 and Windows XP syntax

EDLIN [drive:][path]file name [/B]

/B Ignores end-of-file (Ctrl+Z) characters.

Edlin examples

The example below demonstrates the basic steps needed to edit the autoexec.bat. Below demonstration illustrates both what you would see and what you would type. What you type is displayed in red text.

EDLIN C:\AUTOEXEC.BAT
*L

The line above would display the contents of the autoexec.bat that are demonstrated below (contents may vary).

1: @echo off
2: cls
3: prompt $p$g
4: path=c:\dos

In the example below, we choose one of the lines to edit, which is line number 4. Once you have chosen a line number to edit and press Enter, edlin will then display the line that you are editing with a blank line beneath it. If you press Enter without typing anything, this line is not changed. To make changes, type the information you want to place on this line and press Enter.

*4
4:path=c:\dos
path=c:\windows

Once changes are made, ensure the changes are correct by typing L again to list the file. If the changes are correct, type E save and quit editing the autoexec.bat. However, if you do not want to save the changes, type Q and press Enter to quit without saving the changes.

Helpful tips

  • Use the ";" (semicolon) between multiple commands to execute all commands at once.
  • Use the "." (period) in your command statements, which represents the current line. For example, 1,.,5c would copy line 1 to current line and insert the copied text before line 5.