Internet Windows Android

Copying a file in shell programs is done by a command. Copying files

COPY Command when running on the command line, allows you to copy one or more files. The command has the syntax: COPYsource[+ source [+ ...]][result ]. The source is the name of the file being copied, and the result is the directory where the copy of the file will be placed and/or the name of the file to be created.

For example, let's create some file on drive "C" (I created a text file "robot.txt"), and on drive "D" some folder (I created folder "folder1"). Then the command to copy the file "robot.txt" to the folder "folder1" looks like this: copy robot.txt d:\folder1

If you want to copy a file, while changing its name, you must write the following command: copy robot.txt d:\folder1\file.txt In this case, the file "robot.txt" will be copied to the folder "folder1", but with the name "file.txt".

In order to copy all files with the selected extension, you need to put an asterisk "*" instead of the file name. For example, let's create a folder on the C drive (I created the papka folder) and copy all the text files from the folder1 folder located on the D drive into it. The command will look like: copy d:\folder1\*.txt c:\folder

If no directory is specified as [result], the copy command will copy the file(s) and place them in the current directory. In this case, the copied files will have the same name, date and time of creation as the original file. For example, let's create a text file with the name "robot1.txt" in the "folder1" folder located on the "D" drive. After that, in the command line, change the current directory from "C:\>" to "C:\Papka". Then the command copy d:\folder1\robot1.txt will copy the file "robot1.txt" from the folder "folder1" and place it in the current directory, i.e. to the "papka" folder located on the "C" drive. Moreover, the name, date and time of creation of the copied file will be identical to the original file.

In order to copy all files from a specific directory, you need to put an asterisk "*" instead of the file name and put an asterisk "*" instead of the file extension. For example, let's create several files in the "folder1" folder with different extensions (Word document, Rar archive, etc.). Then the command to copy all the files from folder "folder1" to drive "C" will look like: copy d:\folder1\*.* c:\


[Source] or [result] of copying can be not only files, but also various devices of the computer. The following device names are supported on Windows:

  • LPT1 - LPT3 (parallel ports).
  • COM1 - COM3 (serial ports).
  • CON (terminal, output is the computer screen, input is the keyboard).
  • PRN (printer).
  • AUX (device connected to serial port 1).

For example, using the command line and "copy" command, you can create a text file and write information to it: copy con f1.txt . The copy con f1.txt command will create a text file "f1.txt" and copy the characters that you will enter from the keyboard into it.

After entering the copy con f1.txt command, press Enter and enter the words that need to be saved (I entered command com). After entering, you must put an end-of-file sign (press Ctrl + Z).
With the copy command, you can merge multiple files into one file. For example, let's create two files f2.txt and f3.txt on the C drive (we created the f1.txt file earlier) and write some information to these files. Then the command copy f1.txt+f2.txt+f3.txt d:\f4.txt will copy the contents of the files "f1.txt", "f2.txt", "f3.txt" to the file "f4.txt", which will be automatically created on the "D" drive.

If you do not specify file - [result] when merging files, then all information will be saved in the first file. For example, the command copy f1.txt+f2.txt+f3.txt will add the contents of f2.txt and f3.txt to the contents of file f1.txt

Key /Y disables the output of the file replacement message. By default, when copying files, if such a file exists, a message is displayed warning about the replacement. The user can agree to the replacement (press Y) or disagree (press N). The /Y switch disables this message and copying occurs immediately. For example, let's create a vov.txt file on drive C and copy it to drive D: copy vov.txt d:\
Then copy this file again. This displays the message "Replace d:\vov.txt [path]filename[.type][n:][route]

The file is copied to another drive and/or directory

under the same name.

C:\>copy a:*.* c:

Copy all files from drive A: to the current directory of drive C:.

C:\>copy\work\DOS

Copy all files in the WORK directory to the DOS directory.

C:\>copy\doc\abc\

Copying all files in the ABC directory to the root.

Renaming copy.

COPY [n:][path]filename[.type]

[n:][path]filename[.type]

The file gets a new name when copied.

C:\>copy pr1 pr2

The file named PR1 is copied to the same directory and named PR2.

C:\>copy \work\*.txt \doc\*.doc

When transferring files from WORK to DOC, their types will change from TXT to DOC.

Copying with connection of files.

COPY [n:][path]filename[.type]

[+[n:][path]filename[.type]...]

[n:][route][filename[.type]]

Parameters A,B,V mean:

V - sets the disk write check mode;

A - defines text files;

B - defines binary files.

C:\> copy pr1+pr2+pr3 pr4

The file named PR4 is formed by concatenating the files PR1, PR2 and PR3.

If the resulting file is not specified, then the connected files will be written to the file whose name is specified first (in the above example, to the PR1 file).

The COPY command has other uses besides copying files from one directory to another. The fact is that all external devices connected to the machine have conditional names. Some names are reserved for standard devices:

PRN - main (1st) printer;

LPT1 is another name for the main printer;

LPT2 - additional (2nd) printer;

AUX - main (1st) communication channel;

COM1 - another name for the 1st communication channel;

COM2 - additional (2nd) communication channel;

CON - "console", that is, display + keyboard;

NUL is a "null device" used for debugging.

The COPY command can be used to exchange information with devices. In this case, instead of specifying the path and file name as the source or, more often, the destination, the name of the device is specified.

C:\>copy docum.docprn

The file named docum.doc is copied to the PRN device, i.e. the printer.

C:\>copy con t.bat

The file named T.BAT is created as a result of copying from the CON device, that is, by entering text from the keyboard (the text entered must end with an end sign that occurs when the keys are pressed simultaneously<УПР- Z>).

8.2. Renaming a file - RENAME (REN) command

Command specification:

REN [n:][route]filename[.type] filename[.type]

The first argument specifies the old filename, the second the new one.

The first argument may be preceded by a path prefix indicating in which directory the rename is being made. By default, renaming occurs in the current directory.

C:\WORK>ren a:*.txt *.doc

File types change.

C:\>ren pr1.asm pr2.asm

Replacing the file name PR1 with PR2. The RENAME command does not affect the files themselves.

8.3. Deleting a file is the DEL command.

Command specification:

DEL [n:][route][filename[.type]]

If filename is not specified, then all files in the specified directory or the current directory are deleted. In this case (and also in the case when the pattern *.* is specified), confirmation is requested to perform the operation.

The argument to the DEL command can be a path, a specific file name to delete, or a name pattern.

C:\>del\work\*.txt

All files of the TXT type are deleted in the WORK directory.

Deleted all files in the WORK subdirectory (unless there is a regular file named WORK in the current directory).

The system, before proceeding with the deletion, asks the user a warning question - "Is he sure that everything needs to be deleted?". The user's "yes" response (letter Y) signals the user's confidence and the delete operation is performed. Answer

"no" (letter N) cancels the operation. When deleting, the links to the deleted files are "stripped out" from the corresponding directory. The contents of the files are not destroyed and they can still be "recovered" using special utility programs. If, after the deletion, new files are created on this disk, then it is possible that they will be written to the place of the deleted files. After that, the recovery of deleted files is no longer possible.


1.2.2 MS-DOS operating system MS-DOS is a single-user, single-tasking operating system that provides user interaction with a computer using commands entered by the user (command line interface). Functional parts: - file system (a set of OS tools that provide access to data); -drivers (programs that control the operation of external devices); -command...

A description of these features is beyond the scope of this topic. ATTENTION!!! This command (Prompt) does NOT work when run in NORTON-COMMANDER (from MS DOS command line emulator). The User's dialogue with MS DOS (not using the Dos-Shell) is so primitive that it comes down to entering commands at the MS DOS command line and receiving messages on the Display screen. (Program description- ...

Efficient drivers available to system and application programs. If a running program needs to contact a peripheral device, it tells the operating system which device it needs, and MS-DOS provides it with the appropriate driver. Devices for character-by-character and block data transmission Devices for character-by-character data transmission transfer information ...

With the del *.* command, DOS will ask: Are you sure (Y/N)? (Are you sure?) Press Y and Enter to delete files, N and Enter to cancel the command. Confirmation request. The MS DOS operating system, starting with version 6.0, can request confirmation of the deletion of each file. To do this, you must use the /p mode in the del command. In this case, before deleting each file, the screen will...


Chapter 6. Midnight Commander Program

6.1. Installing Midnight Commander

Although you can use operating system commands such as pwd, ls, cd, mv, mkdir, rmdir, cp, rm, cat, more, etc. to manage the file system and work with files in general, it is much more convenient to do most of the work for file system maintenance using the Midnight Commander program, which visually represents all the actions performed, thereby facilitating the implementation of these operations.

Midnight Commander (or simply mc) is a program that allows you to view the directory structure and perform basic file system management operations. In other words, it's a file manager. If you have experience with Norton Commander (nc) on MS-DOS or FAR on Windows, then you can easily work with mc as well, since even the basic keyboard shortcuts are the same. In this case, in order to work with Midnight Commander, you just need to skim through the material below. For those who are not familiar with nc or FAR (are there any?), I recommend that you carefully study this section, because Midnight Commander makes working with the operating system much easier.

Note

The description in this chapter is based on version 4.5.30 of the program, although it can be used for other versions as well.

Note

This description is fully applicable only when the program is launched from a terminal. When working through a terminal emulator in graphical mode, some statements in the description may not correspond to the reaction of the program, apparently because keystrokes are first intercepted by the graphical shell. Most often, such a discrepancy will occur where we are talking about "hot" keys.

On most distributions, Midnight Commander is not automatically installed when the system is installed. But the corresponding rpm package is usually included on the distribution disk, and installing Midnight Commander from an rpm package is straightforward (see section 10.2 for how to install software from an rpm package). And, since the presence of this program will greatly facilitate your future life, I strongly recommend that you install it as soon as you have installed the OS.

6.2. Midnight Commander Screen Appearance

In order to start Midnight Commander, you need to type mc at the shell prompt and press ‹Enter›. If the program does not start, you need to find where the executable file named mc is located using the find / name mc command, then specify the full path on the command line, for example, I have /usr/bin/mc. After launch, you will see a blue screen, very reminiscent of the screen of the Norton Commander program for MS-DOS or the FAR program by E. Roshal, which is widely used in the DOS window under Windows.

Rice. 6.1. Screen layout when working with Midnight Commander

Almost the entire screen space when working with Midnight Commander is occupied by two "panels" that display lists of files in two directories. There is a menu bar above the panels, and you can switch to the choice of commands in this menu by pressing the ‹F9› key or using the mouse (if you don’t see the menu bar immediately after starting mc, don’t be upset - the menu bar is visible or not, determined by the program settings).

The bottom line is a row of on-screen buttons, each of which is associated with one of the function keys ‹F1› - ‹F10›. You can think of this line as a hint for using the function keys, or you can directly run the corresponding commands by clicking on the on-screen button with the mouse. The display of a line with on-screen buttons can be disabled if you want to save screen space (this will be discussed later when we talk about program settings). These savings are justified for two reasons. Firstly, you will quickly remember the purpose of these 10 keys, and you no longer need a hint (and it is not always convenient to click on these keys with the mouse). Secondly, even if you forgot which key you need to perform the action you need at the moment, you can always use the File menu of the program's main menu (just remember that you can exit to the main menu by pressing ‹F9›). Through the File menu, it is possible to perform any operation from among those associated with the function keys, except for ‹F1› and ‹F9›.

The second line on the screen from the bottom is the command line of the Midnight Commander program (more precisely, the command line of the current shell shell), where you can enter and execute any command on the system. Above it (but below the panels) a "helpful hints" (hint4s) field can be displayed, which can be removed by adjusting the program settings accordingly.

Each panel consists of a title, a list of files in some directory and a mini-status line (the latter may not be visible, this is also set by the program settings). The panel header contains the full path to the directory whose contents are displayed in the panel, as well as three on-screen buttons - "‹", "v" and "›", which are used to control the program with the mouse (these buttons do not work if you run mc in a terminal emulator). The "mini-status" line displays some information about the file or directory that the highlight is currently pointing to (for example, the size of the file and its permissions).

One of the panels is current (active), as evidenced by the highlighting of the directory name in the panel header and the highlighting of one of its rows. Accordingly, in the shell from which the Midnight Commander program was launched, the current directory is the one displayed in the active panel. Almost all operations are performed in this directory. Operations such as copy (‹F5›) or file transfer (‹F6›) use the directory displayed in the second panel as the target directory (to which the copy or transfer is being made).

In the active panel, one line is highlighted. The backlight can be moved using the navigation keys. The built-in file viewer, tooltip viewer, and directory viewer use the same program code to control movement. Therefore, the same key combinations are used for moving (but in each subroutine there are combinations that apply only to it). Here is a brief table that lists the common movement keys.

Table 6.1. General navigation keys.

Key Action to take
‹Up Arrow› or ‹Ctrl›+‹P› Move one line back or up
‹Down arrow› or ‹Ctrl›+‹N› Move forward one line
‹PageUp› or ‹Alt›+‹V› Move one page back
‹Page Down› or ‹Ctrl›+‹V› Move forward one page
‹Home› Move to the beginning
‹End› Moving towards the end

6.3. Getting Help

When working with the Midnight Commander program, you can almost at any time turn to an interactive hint, which is called by pressing the ‹F1› key. The tooltip is organized as hypertext, i.e. it contains hypertext links to other sections of the tooltip. These links are highlighted in blue.

You can use the cursor keys (arrows) or the mouse to navigate in the tooltip view window. In addition to the general combinations of motion control given in Table. 6.1, the help viewer also accepts combinations used in the file viewer subroutine:

Table 6.2. Navigation control when viewing files

In addition to the already listed key combinations, some more can be used that work only when viewing a hint (they are shown in Table 6.3).

Table 6.3. Move control when viewing tooltip.

Key Action to take
‹Tab› Jump to the next link
‹Alt›+‹Tab› Jump to the previous link
Move to the next link or move text up one line
Move to the next link or move text one line down
‹Right Arrow› or ‹Enter› Following the current link
‹Left arrow› or ‹L› Return to previously viewed sections of the tooltip
‹F1› Help on using the tooltip itself
‹N› Go to the next help section
‹P› Skip to the previous help section
‹C› Skip to hint heading
‹F10›, ‹Esc› Exiting the tooltip window

You can use the spacebar to move to the next page of the hint and the ‹B› key to move to the previous page. The program remembers the sequence of transitions by links and allows you to return to previously viewed sections using the ‹ L› key.

If mouse support is enabled (see Section 6.4), you can use the mouse to view the tooltip. By clicking the left mouse button, you follow the link or move through the tooltip text. Right-clicking is used to navigate to previously viewed sections.

6.4. Mouse support

Midnight Commander provides mouse support. This property is implemented if the gpm mouse driver is running, whether you are running on a Linux console or running Midnight Commander through an xterm terminal (even if you are connecting to a remote machine from an xterm via telnet, rlogin, or ssh).

By clicking the left button, you can move the highlight to any file of any of the panels. In order to mark (select) any file, just right-click on the file name. The same right button is used to unmark.

Double-clicking the left mouse button on a file name means an attempt to run the file for execution (if it is an executable program); or, if the extension file contains a program associated with the given extension, this program is launched and the selected file is passed to it for processing.

You can also call up the program associated with the function buttons by clicking on the function button. Clicking on a top menu command brings up a drop-down submenu.

If you click on the top frame of a panel that displays a very long list of files, the list moves back one column. Clicking on the lower frame of the panel leads, respectively, to moving through the list by a whole column forward. This navigation method also works when viewing the built-in tooltip and viewing the Directory Tree window.

If Commander is running with mouse support, you can copy and paste blocks of text by holding down the Shift key. To do this, press the ‹Shift› key and, while holding it down, select the desired piece of text with the mouse, then release ‹Shift›, move the cursor to the desired location, press ‹Shift› again and right-click. Note that this property does not work in a terminal emulator window.

6.5. Panel management

The panels of the Midnight Commander program most often display the contents of the directories of the file system (which is why they are sometimes called directory panels). However, some other information can also be displayed on the panel. This section will show you how to change the look of the panel or how information is presented on the panel.

6.5.1 File list display formats

The appearance of the panels, which display lists of files and subdirectories, can be changed through the commands of the drop-down menus of the left and right panels Left panel(left) and Right panel(Right) of the main menu. If you want to change the format of the file list view in the panel, you can use the command List Format... corresponding (left or right) panel. It is possible to choose one of 4 options for presenting the list of files: Standard(Full) shortened(brief), extended(Long) and User Defined(user).

The "standard" format displays the file name, size, and last modification time.

The "short" format only shows the filenames, allowing the panel to fit two columns (and to see twice as many names).

In the "extended" format, the contents of a directory are represented as the "ls -l" command does. In this format, the panel occupies the entire screen.

If you choose the "user-defined" format, you will need to specify the structure of the displayed information.

When setting the structure, the size of the panel is specified first: "half" (half of the screen) or "full" (full screen). After the panel size, you can specify that the panel should have two columns. This is done by adding the number 2 to the format string. Next, list the field names with an optional field width parameter. The following words can be used as field names:

Name - display the file name.

Size - display file size.

Bsize - Display the size in an alternate form that displays file sizes and only displays "SUB-DIR" or "UP-DIR" for subdirectories.

Type - display a one-character type field. This character can take values ​​from the following subset of characters output by the ls command with the -F option:

○ * (asterisk) - for executable files;

○ / (slash) - for directories;

○ @ (at-sign) - for links (links);

○ = (equal sign) - for sockets

○ - (hyphen) - for byte-oriented devices;

○ + (plus) - for block-oriented devices;

○ | (pipe) - for FIFO type files,

○ ~ (tilde) - for symbolic links to directories;

○ ! (exclamation point) - for broken (stalled) symbolic links (links pointing to a missing file).

Mtime is the time the file was last modified.

Atime is the time the file was last accessed.

Ctime - file creation time.

Perm - a string showing the current file permissions.

Mode is an octal representation of the current file permissions.

Nlink - number of links to the given file.

Ngid is a group identifier (GID), in numerical form.

Nuid - user identifier (UID), in numerical form.

Owner - the owner of the file.

Group - the group that has permissions to the file.

Inode - the inode number of the file.

You can also use the following field names to organize the display of information:

Space - insert a space when displaying.

Mark - insert an asterisk (asterisk) if the file is marked, a space if not marked.

| - insert a vertical line when displaying.

In order to set a fixed field width, you need to add a colon ":", after which you specify the number of positions that are allocated for this field. If you put a "+" symbol after the number, then the specified number will be interpreted as the minimum field width, and, if the screen allows, the field will be expanded.

For example, the "standard" output format is given by the line:

and "extended" - with the line:

full perm, space, nlink, space, owner, space, group, space, size, space, mtime, space, name

And here is an example of a user-defined format:

half name,|,size:7,|,type,mode:3

Displaying a list of files in any of the panels can be done in accordance with one of eight sorting orders:

By name;

By extension;

By file size;

By modification time;

By the time of the last access to the file;

By node number (inode);

No sorting.

You can set the sorting order by selecting the command from the menu of the corresponding panel The sort order… In this case, a dialog box appears (Fig. 6.2), in which, in addition to the desired sort order, you can indicate that sorting is performed in the reverse order (by placing a mark in brackets next to the word Back(Reverse)) and case sensitive.


Rice. 6.2. Sort Order Dialog Box

By default, subdirectories appear at the top of the list, but this can be changed by checking the " Mix files/directories"("Mix all files") commands Configuration menu Settings.

You can display in the panel not all lists of files in a given directory, but only those corresponding to a certain template. Command Filter in the menu of any panel, allows you to specify a pattern that must match the names of files displayed in the panel (for example, "*.tar.gz").

In the menu of each of the panels there is a command Reread(the analogue of which in other programs is usually called "Update"). Command Reread(hot keys ‹Ctrl›+‹R›) updates the list of files displayed in the panel. This is useful when other processes are creating or deleting files. If you have executed the menu command Panelization criterion(redirecting the output of a command to the panel, which will be discussed in Section 6.10), and as a result, the panel contains the results of some program, by command Reread the contents of the directory will be displayed again on the panel.

6.5.2 Other display modes

In addition to the fact that the output format to the file list panel can be set, any panel can be switched to one of the following modes.

Information mode. In this mode (Fig. 6.3), the panel displays information about the file highlighted in another panel and about the current file system (type, free space, and number of free inodes).


Rice. 6.3. Information mode

Tree mode. In the directory tree display mode, one of the panels displays a graphic representation of the directory tree structure (see an example in Fig. 6.4). This mode is similar to the one you'll see when you select the Directory Tree command from the Commands menu, only in the latter case the image of the directory structure is displayed in a separate window.


Rice. 6.4. Directory tree display mode

Quick view mode("Quick View"). In this mode, the panel switches to display the contents of the file highlighted in another panel. For an example in fig. Figure 6.5 is a screen shot of a quick view of the .bashrc file from my home directory.


Rice. 6.5. Quick view mode

When outputting to the "quick view" results panel, the built-in file viewer is used, so if you switch with the ‹Tab› key to the view panel, you can use all the view control commands, in particular, those listed in Table. 6.1 - 6.2.

"Network connection" and "FTP connection" modes. These two modes are used to display a list of directories located on remote computers. Otherwise, the output format is similar to the formats used to display local directories. If you are interested in how to use these modes, use the program's hint.

6.5.3 Keyboard commands to control panels

To control the operating modes of the panel, you can use the menu commands that were mentioned above, but it is more convenient to use control key combinations.

‹Tab› or ‹Ctrl›+‹i›. Change the current (active) panel. The highlight moves from the panel that was previously active to another panel that becomes active.

‹Alt›+‹G› / ‹Alt›+‹R› / ‹Alt›+‹J›. Used to move the highlight, respectively, to the topmost, middle, or bottommost file currently displayed on the panel.

‹Alt›+‹T›. Cyclically switches the display modes of the list of files in the current directory. With this key combination, you can quickly switch from standard output mode (long listing) to short listing or user-defined mode.

‹Ctrl›+‹\›. Show directory directory and navigate to the selected directory.

‹Home› or ‹Alt›+‹’‹’›. Moves the highlight to the first position of the file list (here I have to deviate from the key convention).

‹End›, ‹Alt›+‹‘›"›. Moves the highlight to the last position of the file list.

‹Alt›+‹O›. If the name of the directory is highlighted in the active panel, and the list of files is displayed on the second panel, then the second panel switches to the mode of displaying the files of the highlighted directory. If the highlight in the active panel points to a file, then the contents of the parent directory of the current one are displayed in the second panel.

‹Ctrl›+‹PageUp›, ‹Ctrl›+‹PageDown›. Only if mc is started from a Linux console: it changes (chdir) to the parent directory ("..") or to the highlighted directory, respectively.

‹Alt›+‹Y›. Moving to the previous directory from the directory navigation history; is equivalent to clicking on the "‹" symbol in the upper corner of the panel.

‹Alt›+‹U›. Moving to the next directory from the directory navigation history; is equivalent to clicking the ">" symbol with the mouse.

6.6. Function keys and menus File

So far, we have only talked about the appearance of the Midnight Commander screen and how to change this appearance. Now it's time to tell you how to work with files using this program.

The most frequently performed operations in Midnight Commander are assigned to the function keys ‹F1› - ‹F10›. We give a summary in the form of a table. 6.4.

Table 6.4. Function keys

Function key Action to take
‹F1› Calls context-sensitive tooltip
‹F2› Calls up a user-created menu
‹F3› Viewing the file pointed to by the highlight in the active panel
‹F4› Calling the built-in editor for the file pointed to by the highlight in the active panel
‹F5› Copying a file or a group of marked files from the directory displayed in the active panel to the directory displayed in the second panel. When copying a single file, you can change its name. You can also specify the name of the directory where the copy will be made (if you need to copy to a directory other than the directory displayed in the second panel)
‹F6› Transferring a file or a group of marked files from the directory displayed in the active panel to the directory displayed in the second panel. As with copying, you can change the name of the file or the target directory.
‹F7› Create a subdirectory under the directory displayed in the active panel
‹F8› Deleting a file (subdirectory) or a group of marked files
‹F9› Calling the main menu of the program (displayed above the panels)
‹F10› Exiting the program

The operations (commands) listed in this table can be performed not only by pressing the corresponding function key, but also by clicking on the on-screen buttons or using the corresponding menu commands. File.

Before performing any of the operations indicated in Table. 6.4 or specified by menu commands, you must select a file or a group of files that will be the objects of the operation. To select only one file, it is enough to move the highlight to it in the active panel (of course, you must first go to the appropriate directory). If you want to perform some operation on a group of files at once, these files should be marked. To mark the file that the highlight is currently pointing to, use the ‹Insert› key or the combination ‹Ctrl›+‹T›. In this case, the file name in the panel is displayed in a different color. The same combinations are used to unmark a file.

You can also select a group of files for further processing using the command Mark a group menu File. This command is used to mark a group of files with a given pattern. Midnight Commander will give you an input line in which you must specify a regular expression that defines the desired group of names. If the option is enabled Shell style samples(see section 6.11), regular expressions are built according to the same rules that apply in the shell shell (see chapter 5). If the option " Shell style samples" is disabled, files are marked according to the rules for processing normal regular expressions (see man ed).

If expressions begin or end with a slash (/), then the mark will be placed on directories, not on files.

The "hot" key for the operation of marking a group of files is the ‹+› key on the numeric keypad.

The "Unmark" operation ("hot" key - ‹-› or ‹\› - backslash) is the opposite of the operation of marking a group of files and uses the same rules for generating templates. Used to unmark a group of files.

The "Invert Mark" (‹*›) operation is used to unmark all marked files in the current directory while simultaneously marking all files that have not been marked.

If the current directory contains many files (so that all of them do not fit on the panel), then before you mark the file, you still need to find it. In such cases, it is convenient to use the key combinations ‹Ctrl›+‹S› and ‹Alt›+‹S›. After pressing one of these combinations, the mode of searching for file names in the current directory by the first characters of the name is initiated. In this mode, the entered characters are displayed not in the command line, but in the search bar. If the Show mini-status mode is enabled, this line is displayed in place of the mini-status line. In this case, in the process of entering characters, the highlight line moves to the next file, the name of which begins with the entered character string. The ‹Backspace› or ‹Del› keys can be used to correct errors. If ‹Ctrl›+‹S› is pressed again, the next matching file is searched. It should be noted that if there are no files in the current directory with names starting with the entered characters, these characters are not displayed in the mini-status line, which just tells you that you will not find the file you are looking for here.

After selecting and marking files for processing, just press one of the function keys to perform the desired operation on the files, such as copy files, move or delete. Viewing or editing files using Midnight Commander is especially convenient, compared to working from the command line, since Midnight Commander has built-in programs for these purposes. But in this section, we will not consider the built-in editor, postponing its description until the chapter on working with text files.

As already mentioned, it is not at all necessary to use the function keys to call the commands associated with them. Any of these commands can be executed through the menu File. In addition to commands associated with function keys, menus File contains the following commands (corresponding "hot" keys are indicated in brackets).

Access rights(‹Ctrl›+‹X›,‹C›). Allows you to change the access rights to the selected or marked files.

Owner/Group(‹Ctrl›+‹X›,‹O›). Allows you to execute the chown command.

Rights (extended). Allows you to change the permissions and ownership of a file.

Symbolic link(‹Ctrl›+‹X›,‹S›). Creates a symbolic link to the current file. We discussed links in detail in Sect. 4.4. Midnight Commander specifies symbolic links by printing "@" in front of the link's name (except for links to subdirectories, which are indicated by the tilde "~"). If the mini-status line is displayed on the screen (the "Show mini-status" option is enabled), then it displays the name of the file pointed to by the link.

Quick directory change(‹Alt›+‹C›). Use this command if you know the full path to the directory you want to change to (which you want to make current).

View command output(‹Alt›+‹!›). By this command, an input line appears on the screen, in which you can enter any command with parameters (by default, it is suggested to use the name of the highlighted file as a parameter). The output of this command will be displayed on the screen through the built-in viewer.

As you can see the menu File contains all the most common commands that we need for normal file processing operations in the current directory. Naturally, the most commonly used operations are associated with function keys. Therefore, let's return to the description of these commands to give some additional explanations.

6.7. File masks for copy/rename operations

When performing copy and move (or rename) operations on files, you have the option to change the names of the copied or moved files. To do this, you must specify a mask for the names of the source files and a mask for the names of the files to be created (destination files). Typically, this second mask is a series of wildcards at the end of the string, specifying the destination of the generated files. Masks are set in the input lines displayed in the window that appears after accessing the copy / transfer commands (Fig. 6.6).

All files matching the source mask will be renamed (copied or moved with new names) according to the destination file mask. If there are marked files, then only marked files that match the specified mask for source files are copied (moved).


Rice. 6.6. Dialog box for renaming files

There are several more options that affect the execution of file copy/move operations, and which are set in the same query window where file name masks are specified, or through the menu command Settings | Configuration.

Option Dereference references(Follow links) determines whether copying hard or symbolic links in the destination directory (and recursively in subdirectories) will create the same links, or will copy the files (and subdirectories) to which these links point.

Option Inside the directory, if any(Dive into subdirs) defines what to do if a subdirectory already exists in the destination directory, the name of which matches the name of the file (directory) being copied (source). By default (the option is disabled), the contents of the source directory are copied to the destination directory. If this option is enabled, then a new subdirectory with the same name will be created in the destination directory, to which copying will be performed.

It is better to show this with an example. Let's say you want to copy the contents of the one directory to the /two/one directory, which already exists. Normally (disabled) mc will just copy all files from one to /two/one. If this option is enabled, files will be copied to /two/one/one.

Option Preserve Attributes(Preserve attributes) determines whether the attributes of the source file will be preserved during copying / moving: permissions, timestamps and, if you are root, the UID and GID of the source file. If the option is disabled, the attributes will be set according to the current umask value.

The procedures for copying and moving files are also affected by setting the option Shell style samples in the Settings / Configuration menu. When this option is enabled, you can use wildcards "*" and "?" in the source mask. They are processed in the same way as it is done in the shell. Only "*" and "\‹number›" are allowed in the receiver mask. The first character "*" in the destination mask matches the first group of wildcard characters in the source mask, the second character "*" matches the second group, and so on. Similarly, the wildcard character "\1" matches the first group of wildcard characters in the source mask, the character "\ 2" for the second group, and so on. The character "\0" corresponds to the whole name of the source file. Let's give a couple of examples.

Example 1. If the source mask is "*.tar.gz" and the destination mask is "/two/*.tgz" and the filename to be copied is "foo.tar.gz", the copy will be named "foo.tgz" and will be in the directory "/two".

Example 2. Suppose you want to swap the name and extension of a file so that "file.c" becomes "c.file". The source mask for this must be "*.*" and the destination mask must be "\2.\1".

When option Shell style samples("Use shell patterns") is off, mc does not automatically group. To specify groups of characters in the source mask that will match the replacement characters in the destination mask, you must use "\(…\)" brackets in this case. This method is more flexible but requires more effort to type in. Here are two examples again

Example 3. If the source mask is "^\(.*\)\.tar\.gz$", copying to "/two/*.tgz" and copying the file "foo.tar.gz", the result will be "/two /foo.tgz".

Example 4. Let's say you want to swap a file name and extension so that names like "file.c" become "c.file".

The source mask for this is "^\(.*\)\.\(.*\)$" and the destination mask is "\2.\1".

When performing copy/move operations, you can also convert the case of characters in filenames. If you use "\u" or "\l" in the destination mask, then the next character in the name will be in upper (capital) or lower (lower) case respectively.

If you use "\U" or "\L" in the destination mask, then all subsequent characters will be converted to the appropriate case, up to the next occurrence of "\L" or "\U", or to the end of the file name.

Using "\u" and "\l" provides more options than "\U" and "\L".

For example, if the source mask is "*" (option Shell style samples enabled) or "^\(.*\)$" (option Shell style samples disabled) and the destination mask is "\L\u*", the filenames will be converted so that the first letters of the name will be uppercase and the rest will be lowercase.

The "\" character in masks is used to override the special interpretation of individual characters. For example, "\\" means just a backslash (as a literal) and "\*" means just an asterisk (asterisk).

6.8. MC messages during file copy/move operations

When you perform file copy, move, or delete operations, Midnight Commander displays a dialog box showing which file(s) is currently being processed and how the processing is progressing. To display the processing process, up to three progress bars are displayed on the screen. The first one (file bar) shows which part of the current file has been processed (for example, copied). The second (count bar) shows what percentage of marked files has been processed at the moment. The third one (bytes bar) shows the share of completed jobs as a percentage of the total volume (in bytes) of marked files. If the option is disabled Operation details(see menu command Settings/Configuration), the last two charts are not displayed.

There are two buttons at the bottom of this dialog box. Clicking on a button Skip will cause processing of the current file to be skipped. Pressing the on-screen button abort terminates the given operation, all remaining files will be skipped.

In the process of performing file operations, you can see three more types of windows.

Error window informs about the error and offers three options to continue. Usually you choose either option Skip in order to exclude from processing the file on which the program stumbled, or abort to cancel the given operation altogether. The third option Repeat, is selected when you managed to eliminate the cause of the failure (for example, using a different terminal).

Confirmation window overwriting appears when you try to overwrite an existing file, i.e. the directory to which you are moving or copying already has a file with the given name. The confirmation window displays the creation time and size of the source file (transferred or copied file) and destination file (which will be destroyed if overwritten).

Below are two questions. The first question ("Overwrite this file?") offers three possible answers:

Agree (button Yes);

Refuse, i.e. skip overwriting the current file (button Not);

Append the contents of the source file to the end of the destination file (button Add to the end).

The answer to the second question ("Overwrite all files?") allows you to make one of 4 possible decisions for all files selected for processing (so that the query window does not appear every time):

Everything- all selected files will be overwritten without additional questions;

Obsolete- only files that were created before the source file will be overwritten (overwritten);

No one- do not overwrite files (but if there is no destination file, then the source will be copied);

Varies in length.

You can refuse to perform the operation if you click the button abort at the bottom of the query window. The desired screen button is selected using the arrow keys or the tab key.

Request window recursive delete appears when you try to delete a non-empty directory. By button Yes directory will be deleted along with all files, Not means not deleting the directory, Everything must be chosen if you have marked a group of subdirectories for deletion and are sure of your choice, No one- to skip all non-empty directories from among the marked ones, abort means to refuse to perform the delete operation. choose Yes or Everything only if you are really sure that you want to delete a directory with all its nested subdirectories.

If you have marked a group of files for processing, then after the operation is completed, only those files that have been successfully processed will be unmarked. Skipped files will remain flagged.

6.9. shell command line

As mentioned when describing the appearance of the Midnight Commander screen, there is always a shell command line at the bottom of the screen.

In order to run any command of the operating system while working with Midnight Commander, you must either type the name of the corresponding program in the command line, or select it in one of the panels (by moving the highlight to the name of the program file), and then press the ‹Enter› key . If you press the ‹Enter› key while the highlight is pointing to a non-executable file name, Midnight Commander compares the selected file's extension with the extensions in the "extensions file" ~/mc.ext. If there is a subsection in the extension file that specifies procedures for processing files with the given extension, then the file is processed in accordance with the commands specified in this subsection. Simple macro substitutions are performed before processing.

Often, entering commands requires entering a large number of characters (especially considering that it is necessary to specify the command parameters and, in particular, the full names of the files to be processed, with paths). To facilitate typing in Midnight Commander, there are several keyboard commands that allow you to reduce the number of keystrokes while typing and editing commands on the command line.

‹Alt›+‹Enter›. Copies the highlighted file or directory name to the command line.

‹Ctrl›+‹Enter›. Same as ‹Alt›+‹Enter›, but only works in the console.

‹Alt›+‹Tab›. Attempts to complete the "completion" operation of a filename, command name, variable, username, or hostname (depending on what you started typing and which command element you are entering), that is, it tries to guess characters that you have not yet typed, based on the list of files in the current directory, the list of commands, etc.

‹Ctrl›+‹X›, ‹T›. Copies to the command line the names of marked files (or the highlighted name if none are marked) from the active panel.

‹Ctrl›+‹X›, ‹Ctrl›+‹T›. Copies the names of marked files from the passive panel to the command line.

‹Ctrl›+‹X›,‹P›. Copies the name of the current directory (that is, the directory displayed in the active pane) to the command line.

‹Ctrl›+‹X›, ‹Ctrl›+‹P›. Copies to the command line the name of the directory displayed in the passive panel.

‹Ctrl›+‹Q›. Inserts characters that are somehow interpreted by Midnight Commander itself (for example, the "+" character).

‹Alt›+‹P›. Causes moving one command back through the list of previously run commands (command history).

‹Alt›+‹N›. Move one command forward in the command history.

‹Alt›+‹H›. Displays the history of the current input line (for the command line, the command history).

Input lines are not only the shell command line, but also input lines in the dialog boxes of various subroutines. In all cases, when the input line appears on the screen, you can use the control key combinations listed in Table. 6.5.

Table 6.5. Commands for managing the input line.

Key combination Action to take
‹Ctrl›+‹A› Moves the cursor to the beginning of the line
‹Ctrl›+‹E› Moves the cursor to the end of the line
‹Ctrl›+‹B› or ‹←› Moves the cursor one position to the left
‹Ctrl›+‹F› or ‹→› Moves the cursor one position to the right
‹Alt›+‹F› Moves the cursor one word forward
‹Alt›+‹B› Moves the cursor one word back
‹Ctrl›+‹H› or ‹Backspace› Deletes the character preceding the cursor
‹Ctrl›+‹D› or ‹Delete› Deletes the character at the cursor position
‹Ctrl›+‹@› Sets a mark to cut (copy to clipboard) a piece of text
‹Ctrl›+‹W› Copies the text between the cursor and the label to the clipboard, removing the text from the input line
‹Alt›+‹W› Copies the text between the cursor and the label to the clipboard (without removing it from the input line)
‹Ctrl›+‹Y› Inserts the contents of the buffer into the input line before the cursor position
‹Ctrl›+‹K› Deletes text from the cursor to the end of the line
‹Alt›+‹P› and ‹Alt›+‹N› These combinations are used to move through the command history. ‹Alt›+‹P› moves to the previous command, ‹Alt›+‹N› to the next
‹Ctrl›+‹Alt›+‹H› or ‹Alt›+‹Backspace› Delete preceding word
‹Alt›+‹Tab› Attempts to complete the input of a filename, command, variable, username, or hostname

6.10. Menu Commands

Dropdown submenu Teams The main menu allows you to perform a number of file system management operations, as well as execute some commands that change the appearance of the Midnight Commander panels and the information displayed in the panel.

When accessing the menu command Directory tree a window is displayed showing the directory structure of the file system.

The directory tree can be called up in two ways: through the command Directory tree from the menu Teams and team Wood from the right or left panel menu.

To avoid long delays during directory tree creation, Midnight Commander builds the tree by looking at only a small subset of all directories. If the directory you want is not displayed, go to its parent directory and press ‹Ctrl›+‹R› or ‹F2›. If the directory contains no nested subdirectories, nothing will happen. Otherwise, one more level of the subdirectory tree will expand.

There are two modes for displaying the directory tree. In static navigation mode, only the ‹› and ‹↓› keys are used to select a directory (ie move the highlight to another directory name). All subdirectories currently known to the program are shown. In dynamic mode, the ‹› and ‹↓› keys are used to jump to the neighboring directory of the same level. The ‹←› key is used to go to the parent directory, and the ‹→› key moves to the descendants of the current directory, i.e. one level lower. This displays only the overlying directories (including the parent and above), neighboring directories of the same level and immediate children. The view of the directory tree dynamically changes after each movement through the tree.

The following key combinations can be used to control directory tree browsing:

All movement control keys work (see Table 6.1).

‹Enter›. In the directory tree view window, pressing this key will exit the view mode and display the list of files in the selected directory in the active panel. When displaying a directory tree in one of the panes, pressing the ‹Enter› key displays the corresponding directory in the second pane, leaving the tree in the current pane.

‹F3›. Remove the current directory from the tree. This command is only used to remove erroneously displayed tree branches. If you try to delete an existing directory, you will receive an error message. That is why in the line explaining the purpose of the function keys, the ‹F2› key is indicated by the word Forget.

‹F4› (Static/Dynamic). Switch between static (default) and dynamic tree navigation.

‹F5›. Copy subdirectory (an input line appears in which you need to specify where to copy).

‹F6›. Move subdirectory.

‹F7›. Create a subdirectory in the current directory.

‹F8›. Delete the highlighted directory from the file system.

‹Ctrl›+‹S› or ‹Alt›+‹S›. Find the next directory that matches the given search pattern. If no such directory exists, it simply shifts the highlight down one line.

‹Ctrl›+‹H› or ‹Backspace›. Deletes the last character in the search string (pattern).

‹Any other character›. This character is added to the search pattern and moved to the next directory name that matches the pattern. In the directory tree browsing mode, you must first activate the search mode with the keys ‹Ctrl›+‹S›. The search pattern will be displayed in the mini status bar.

The following actions are only possible in the directory tree view window and are not supported when tree view in one of the panels

‹F1› (Help). Invoke a tooltip displaying the help section about the directory tree window.

‹Esc› or ‹F10›. Exit the directory tree window. There is no change to the current directory.

A mouse is supported in the directory tree browser. Double clicking is the same as pressing the ‹Enter› key.

Command File search(hot keys ‹Meta›+‹?› or ‹Esc›,‹?›) dropdown menu Command allows you to find a file on disk with the given name. After selecting this menu command, you are first asked for the name of the searched file and the name of the directory from which to start the search. By pressing the on-screen button Wood, you can select the search start directory from the directory tree. In field Content(Contents) you can specify a regular expression according to the rules of the egrep command. This means that characters that have a special meaning for egrep must be preceded by a "\", for example, if you need to find the string "strcmp(" you must specify the search pattern in the form "strcmp \(". To start search, press the screen button Farther. During the search, you can pause it with the button Stop and continue on the button Proceed.

The list of found files can be viewed by moving using the ‹Up Arrow› and ‹Down Arrow› keys. Button Go is used to change to the directory where the highlighted file is located. Button Repeat is used to set the parameters of a new search.

Button Output is used to exit the search mode.

Clicking on a button Panelization will cause the search results to be displayed on the current active panel, so that you can perform some other actions with the selected files (view, copy, move, delete, and so on). After displaying on the panel, you can press ‹Ctrl›+‹R› to return to the normal file list.

In addition, it is possible to specify a list of directories that the command File search will skip during the search (for example, you know that the file you are looking for is not on the CD-ROM, or you do not want to search directories mounted via NFS over a very slow link). The directories to skip should be specified in the find_ignore_dirs variable in the Misc section of your ~/.mc/ini file.

Directory names are separated by colons, as follows:

find_ignore_dirs=/cdrom:/nfs/wuarchive:/afs

You can use output redirection to panel (see below Panelization criterion) to perform some complicated sequences of actions, while File search only allows simple queries.

Command rearrange panels(‹Ctrl›+‹U›) swaps the contents of the right and left panes.

On command Disable Panels(‹Ctrl›+‹O›) displays the output of the most recently executed shell command. This command only works via xterm and on the Linux console.

On command Compare directories(‹Ctrl-X›, ‹D›) compares the contents of the directories displayed in the left and right panes.

There are three comparison methods. The fast method compares only the size and creation date of files with the same name. This will highlight files in both directories that are not in the second directory, or newer versions of the corresponding files. After that you can use the command Copy(‹F5›) to make the contents of the directories the same.

The byte-by-byte method compares the contents of files (byte by byte). This method is not available if the machine does not support the mmap(2) system call. When comparing by size, only the sizes of the corresponding files are compared, and the creation date is not checked.

Menu command Panelization criterion(which would be more properly called "Redirecting output to a panel") allows you to execute an external program by making its output the contents of the currently active panel (a typical example is panelizing the output of a find command). For example, if you want to perform some action on all symbolic links in the current directory, you can use the command Panelization criterion to run the following command:

After executing this command, the current panel will not display the contents of the corresponding directory, but only all the symbolic links located in it.

If you wish, you can save frequently used panelization commands under separate descriptive names so that you can quickly call them by those names. To do this, type the command in the input line (line "Command") and press the button Add. After that, you will need to enter a name by which you will call the command. Next time, you will just need to select the desired name from the list, and not enter the entire command again.

Menu command Team History displays a window with a list of previously executed commands. The highlighted line from the history can be copied to the shell command line (moving the highlight - with the ‹Up Arrow › and ‹Down Arrow › keys, copying - with the ‹Enter› key).

The command history can also be accessed using the key combinations ‹Alt›+‹P› or ‹Alt›+‹N›, but in this case you do not see the window with the list of commands. Instead, one command from the list is output to the command line and the combination ‹Alt›+‹P› changes this command to the previous one, and ‹Alt›+‹N› changes to the next command from the command history.

Menu command Directory directory(‹Ctrl›+‹\›) allows you to create a list of directories that are frequently used, and provide a quick jump to the desired directory from this list. To do this, a list of labels (conventional names) assigned to the most frequently used directories is created. This list can be used to quickly jump to the desired directory. Using the Directory Directory dialog box, you can add a new label to the list or delete a previously created label/directory pair. To add a label, you can also use the key combination (‹Ctrl›+‹X›, ‹H›), by which the current directory is added to the directory directory. The program will prompt you to enter a label for this directory.

Menu command Background jobs allows you to control background jobs launched from Midnight Commander (such jobs can only be copy and move files). Using this menu command or hot keys ‹Ctrl›+‹X›, ‹J›, you can stop, resume or cancel any of the background jobs.

After selecting the menu command Extension File you get the opportunity to edit the mc.ext file, in which you can associate with a certain file extension (name ending after the last dot) a program that will be launched to process (view, edit or execute) a file with such an extension. The selected program will be launched after highlighting the file name and pressing the ‹Enter› key.

Command Menu File used to edit the user menu (which appears after pressing the ‹F2› key).

6.11. Setting up Midnight Commander

The Midnight Commander program has a number of settings (options), each of which can be turned on or off, for which there are several dialog boxes accessible through the menu Settings. An option is enabled by placing (using the spacebar) an asterisk or an "x" in parentheses before the option name. Consider the menu commands sequentially Settings, through which these options are enabled / disabled.

Command Configuration.

When this menu command is selected, the dialog box shown in Fig. 6.7. The configuration options set in this window are divided into three groups: " Panel settings", "Pause after execution" And " Other settings".

In field " Panel settings" you set the values ​​of the following parameters.

Show backup files. By default, Midnight Commander does not show files whose names end in "~" (similar to the -B option of the ls command).

Show hidden files. By default, Midnight Commander shows all files, including files whose names start with a dot (like ls -a).


Rice. 6.7. Configuration Options Settings Window

The mark moves the cursor. When you mark a file (using ‹Ctrl›+‹T› or ‹Insert›), by default the highlighting on the file name is shifted one line down.

Dropdown menu on call. If this option is enabled, then when you call the main menu by pressing the ‹F9› key, a list of menu commands (drop-down menu) will be immediately displayed. Otherwise, only the commands of the main menu are activated and you must (after selecting one of them with the arrow keys) press the ‹Enter› key, or select the desired command by the first letter of the name, and only after that you will be able to select the command from the drop-down menu.

Mix files/directories. If this option is enabled, file and directory names are displayed interspersed. If this option is disabled, directories (and directory links) are shown at the beginning of the list, and filenames after all directory names.

. This option is disabled by default. If you enable it, Midnight Commander will use the following trick to list the contents of a directory: the contents of the directory are reread only if the entry in the directory's i-node has changed, that is, if files have been created or deleted in the directory; if only the entries in the i-node of the directory files have changed (the file size, access mode or owner has changed, etc.), the contents of the panel are not updated. In this case (if the option is enabled) you must update the list of files manually (using the ‹Ctrl›+‹R› keys).

Field Pause after execution. After executing your command, Midnight Commander may provide a pause so that you can review and examine the output of the command. There are three options for setting this option.

Never. This means that you don't want to see the output of the command. On a Linux console or using an xterm, you can view this output by pressing ‹Ctrl›+‹O›.

On "stupid" terminals. The pause will be created on terminals that are unable to display the output of the last command executed (that is, any terminal other than an xterm or Linux console).

Is always. The program will pause after executing any command.

In field Other settings you set the values ​​of the following parameters:

Operation details(Verbose operation). This switch determines whether copy, move, and delete operations will display an additional window showing the progress of the operation. If you have a slow terminal, you can disable this output. It turns off automatically if your terminal speed is less than 9600 bps.

Calculate total size(Compute totals). If this option is enabled, Midnight Commander counts the total number of processed files and their total size before performing copy, move, and delete operations, and shows the progress of the operation on these files in the form of a bar chart (although this slightly slows down the operations). This option does not work if the "Operation Details" option is disabled.

Shell style samples(Shell patterns). By default, the commands for marking a group of files (Select), unchecking (Unselect), and listing files by filter (Filter) use regular expressions, which are built according to the rules in force in the shell. To achieve this effect, the following conversions are performed: "*" is replaced by ".*" (zero or more characters); "?" is replaced with "." (exactly one character) and "." is replaced by a regular dot (literal dot). If this option is disabled, regular expressions must be built as described in man 1 ed.

Autosave settings. If this option is enabled, then when you exit the Midnight Commander program, the values ​​of all configurable parameters are saved in the ~/.mc/ini file.

Automatic menus. If this option is enabled, the user menu will be automatically called up on the screen when the program starts. This is useful if the computer is used by inexperienced users (operators) who need to perform only standard operations.

Built-in editor. If this option is enabled, then the built-in editor is called to edit files. If this option is disabled, then the editor specified in the EDITOR environment variable will be used. If no such editor is specified, vi will be invoked.

Embedded Preview. If this option is enabled, the built-in viewer is invoked to view files. If the option is disabled, the program specified in the PAGER environment variable is invoked. If no such program is specified, the view command is used.

Addendum: show all. While entering commands, Midnight Commander can perform "Complete Typing" by pressing ‹Alt›+‹Tab› keys, trying to guess the end of the command being entered. By default, the first time you press ‹Alt›+‹Tab›, it looks for all possible completions, and if the completions are ambiguous (there are many different options), it only beeps. A second press of ‹Alt›+‹Tab› displays all possible completions. If you want to see all possible completions after the first press of ‹Alt›+‹Tab›, enable this option.

Rotating indicator. If this option is enabled, Midnight Commander displays a spinning dash in the upper right corner as an indicator that some task (operation) is being performed.

Lynx style navigation. If this option is enabled, you can use the ‹→› keys to navigate to the currently highlighted directory and ‹←› to navigate to the parent directory of the current directory (assuming the command line is empty). By default, the option is disabled.

Extended chown command. If this option is enabled, chmod or chown commands will be invoked instead of the Extended chown command.

Change directory by links. Setting this option causes Midnight Commander to follow a logical chain of subdirectories when executing directory change commands, both in the panel and with the cd command. This is how bash behaves by default. If this option is not enabled, Midnight Commander will follow the real directory structure when executing the cd command, so if you entered the current directory by reference to it, then cd .. will find you in its parent directory, and not in the directory where is the link.

Safe removal. If this option is enabled, it will be more difficult to inadvertently delete a file. The deletion confirmation dialog box changes the default button from "Yes" to "No" and the operation to delete a non-empty directory must be confirmed by selecting the "Yes" button. This option is disabled by default.

Dialog window Appearance gives you the opportunity to change some parameters of displaying the main window of the Midnight Commander program on the monitor screen (Fig. 6.8).

You can display or cancel the display of the main menu line, command line, hint line, mini-status, function key hint line. On a Linux- (or SCO-) console, you can set the number of lines that will be left to display the output of a command.

You can also specify whether the panels should be laid out horizontally or vertically, and resize the panels.


Rice. 6.8. Program appearance settings

By default, all information is displayed in one color, but you can make it so that permissions and file types are highlighted in other colors. If permission colorization is enabled, the perm and mode fields in the output formats showing the permissions of the user running the Midnight Commander program are highlighted in the color specified by the selected keyword in the ~/.mc/ini section of the initialization file. If color highlighting of file types is enabled, then directories, memory dumps (core files), executable files, etc. are highlighted in different colors.

If the option is enabled mini status, at the bottom of each panel a line of information about the highlighted file or directory of each panel is displayed.

In the dialog box Character Bits…(Fig. 6.9) you specify in what format your terminal will process (enter and display on the display) information represented by bytes (for example, written in a file).


Rice. 6.9. Output setting

If the terminal supports only 7-bit output, then you need to select the setting 7 bit. By choosing "ISO-8859-1" you will get all the characters from the ISO-8859-1 table, and choosing to install Full 8-bit output makes sense on those terminals that can display all 8-bit characters. To see Cyrillic on the screen when viewing or editing files in Midnight Commander, set the options Full 8-bit output And Full 8-bit input(as in Fig. 6. 9) and press the on-screen button Farther.

Setting the option Full 8-bit output allows you to view files typed in KOI8-R encoding on the screen. If you need to work with other encodings (for example, cp1251), then keep in mind that Valery Studennikov wrote a wonderful patch that allows you to select code pages when viewing and editing files in Midnight Commander (see http://www .linux.zp.ua:8100/mc/ or http://www.sama.ru/~despaire/mc/my-patches.html). Only you will have to compile the mc version yourself with this feature. However, this is not so difficult (see Section 10.3).

Using the menu command Confirmations, you can make it so that before performing the operations of deleting, overwriting and running the file for execution, as well as before exiting the mc program, an additional confirmation request is issued (or cancel such requests, which is somewhat risky).

Command Key recognition... (Learn keys…) brings up a dialog box where you can test the operation of some keys (‹F1› - ‹F20›, ‹Home›, ‹End›), which do not work on all types of terminals. A table with the names of the keys to be tested appears in the dialog box. You can move the highlight through the titles using the ‹Tab› key or the keys used in the vi editor (‹h› - left, ‹j› - down, ‹k› - up, ‹l› - right). If you press the arrow keys once, after which the OK mark appears next to their names in the table, then they can also be used to control movement.

To test the operation of the keys, you need to press each key listed in the table. If it works properly, an OK mark will appear next to its name in the table. After the appearance of such a mark, the key begins to work in its normal mode. For example, the first press of the ‹F1› key will only display the OK mark (if the key is working properly), and the next time you press the help window will be displayed. The same applies to the arrow keys. The ‹Tab› key always works. If a key does not work, then after pressing it, the OK mark will not appear. In this case, it is possible to link the reaction of the system, which should have followed the pressing of a non-working (missing) key, with pressing another key or key combination. To do this, move the highlight to the name of the broken key (using the mouse or the ‹Tab› key) and press ‹Enter› or the spacebar. A red window should appear asking you to press a key that will be used instead of a broken one. To cancel the operation, press ‹Esc› and wait until the red window disappears. Or select and press the key combination that will serve as a replacement for the broken key (and also wait for the window to close). When you have finished testing and configuring all the keys, you can save these settings in a section of your ~/.mc/ini file (where TERM is the name of the terminal you are using) or refuse to remember the changes. If all keys work normally, then saving is of course not required.

Command Virtual FS calls a dialog box in which you can set the values ​​of some parameters related to the use of virtual file systems.

I hope the material in this section will get you started with Midnight Commander. But the possibilities of this program are much wider than described in this section. In ch. 12 you will also read about Midnight Commander's built-in CoolEdit editor. In addition, you can use the built-in tooltip called by the ‹F1› key. Translation of the help file into Russian (in the form of a bzip2-archive) can be found at http://linux-ve.chat.ru. Unzip it, place it in the /usr/lib/mc directory, replacing the mc.hlp file located there, and you will receive a prompt in Russian when you press the ‹F1› key.

Notes:

Please note that this text was written in 2001.

(Comment sent by M. Zotov) This can be done when copying any number of files, if copying is done in accordance with some template.

In the DOS era, not every ordinary user could work with this operating system. The difficulties were both in the perception of the file system itself, and in remembering all the commands necessary to control the computer. The command line prompt was all DOS provided to the user. This line contains the address of the current directory. The user had to remember all the directories, the names of all the files in them. That is why DOS in its pure form was practically not used by anyone. applied wrappers- operating system add-ons that make it easier to work with operating system commands and directory structures, as well as change the visual perception of the operating system.

One of the most popular file shells of that era was Norton Commander. It consisted of two windows: current and target. The windows displayed all the directories and files of the directories they represented. It was possible to copy, move a file from the current directory to the target by pressing just one key. Without this wrapper, in order to copy a file such as "macros.txt" one would have to write the following command

Copy macros.txt > c:\program files\xerox

All commands of the shell program were implemented by pressing the function keys, their list is placed under the windows. The shell program provided the ability to also use the command line. The figures show the Norton Commander shell programs and the modern Far.

Figure 2 Norton Commander

Figure 3 Far

In the early 90s, the MS-Windows 3.x graphical shell gained immense popularity all over the world. This wrapper program was of a slightly different kind. Its graphical interface, instead of a set of complex commands from the keyboard, allows you to select them with the mouse from the menu almost instantly. The Windows operating environment, working in conjunction with the DOS operating system, implements all the properties necessary for the user's productive work, including multitasking. It provided the ability to open each directory in a separate window and operate on files by clicking on them with the mouse. The Windows 3.1 shell program can be thought of as a precursor to the Windows graphical operating system.

Figure 4 Windows 3.1

Modern tools for working with files and directories are called file managers. It would seem that the Windows operating system provides the most convenient interface and the ability to work with files. However, among professionals, file managers are highly preferred. This is due to the fact that the graphical environment slows down the work with the computer (oddly enough). The thing is that in order to perform some kind of manipulation with a graphic object on the screen, you first need to find it. Then press the menu call button and FIND the desired menu item, and then get to it with the cursor. This requires increased attention, and, consequently, tension. In file managers, hotkeys are used, which allows you to perform the operation of searching, copying, deleting (etc.) by pressing one or two keys. In addition, file managers provide the ability to quickly enable frequently used application programs and utilities. For example, an archiver program can be launched directly using the button on the toolbar (rather than searching for the executable file of this program in folders).


The most popular file manager is Total Commander. The principle underlying its interface has not changed at all since the DOS era.

Figure 5 Total Commander