


What is the difference between vi and cat in linux
The difference between vi and cat: 1. Cat is a text printing command, while vi is a text editor; 2. The cat command is used to output file content information to the console, but it cannot edit files. The vi command can output file contents and edit (delete, search, replace) files.
#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
cat command introduction
The original meaning of the cat command is concatenation (concatenate), which is used to connect the contents of multiple files and output them to the standard output. stream (the standard output stream defaults to the screen). In actual application, we often use it to display file contents. If you are familiar with the type command under MS-DOS, I believe it is not difficult to master the cat command. Common examples of this command are as follows:
cat file1.txt
Display the contents of the file1.txt file;
cat file1.txt file2.txt
Display the contents of file1.txt and file2.txt files;
cat -n file1.txt
Display the contents of file1.txt file and display the line number;
vi command introduction
vi is the abbreviation of "Visual Interface". Its status on Linux is like the Edit program on DOS. It can perform many text operations such as output, delete, find, replace, block operations, etc., and users can customize it according to their own needs, which is not available in other editing programs.
vi is not a typesetting program. It is not like Word or WPS that can arrange fonts, formats, paragraphs and other attributes. It is just a text editing program.
vi has no menu, only commands, and there are many commands. Due to space limitations, this article only introduces commonly used commands.
Vi has three basic working modes: command line mode, text input mode and last line mode.
-
Command line mode:
At any time, no matter what mode the user is in, just press the "ESC" key to enter vi into the command line mode; when When you enter the vi command in the shell environment to start the vi editor, you are also in this mode.
In this mode, users can enter various legal vi commands to manage their own documents. At this time, any characters entered from the keyboard are interpreted as editing commands. If the entered characters are legal vi commands, vi will complete the corresponding actions after accepting the user commands (but it should be noted that the entered commands is not displayed on the screen). If the characters entered are not legal commands for vi, vi will sound an alarm.
-
Text input mode:
In command mode, enter the insert command i, append command a, open command o, modify command c, replace command r or replace command s can enter text input mode. In this mode, any characters entered by the user are saved by vi as file content and displayed on the screen. During the text input process, if you want to return to the command mode, just press the "ESC" key.
-
Last line mode:
In command mode, the user can enter the last line mode by pressing the ":" key. At this time, Vi will display the last line of the window. (usually the last line of the screen) displays a ":" as the last line mode prompt, waiting for the user to enter a command. Most file management commands are executed in this mode (such as writing the contents of the editing buffer to a file, etc.) After the last line of commands is executed, vi automatically returns to the command mode.
If you change your mind while entering a command in the last line mode, you can press the "ESC" key or use the backspace key to delete all the entered commands, and then press the backspace key again to make vi Return to command mode.
The difference between cat and vi/vim
The cat command is a text printing command under the Linux system. Use For outputting a text message to the console, the input of this command is similar to using word to open a document, but the document cannot be edited.
The vi/vim command is a command used to view and edit text under the Linux system. It can not only view but also edit.
Extension: The difference between vi and vim
vi does not need to be installed, open the code, the color is the same (black)
vim requires additional installation, open the code , use color to distinguish codes
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of What is the difference between vi and cat in linux. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Docker process viewing method: 1. Docker CLI command: docker ps; 2. Systemd CLI command: systemctl status docker; 3. Docker Compose CLI command: docker-compose ps; 4. Process Explorer (Windows); 5. /proc directory (Linux).

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

VS Code is available on Mac. It has powerful extensions, Git integration, terminal and debugger, and also offers a wealth of setup options. However, for particularly large projects or highly professional development, VS Code may have performance or functional limitations.

VS Code is the full name Visual Studio Code, which is a free and open source cross-platform code editor and development environment developed by Microsoft. It supports a wide range of programming languages and provides syntax highlighting, code automatic completion, code snippets and smart prompts to improve development efficiency. Through a rich extension ecosystem, users can add extensions to specific needs and languages, such as debuggers, code formatting tools, and Git integrations. VS Code also includes an intuitive debugger that helps quickly find and resolve bugs in your code.

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

VS Code One-step/Next step shortcut key usage: One-step (backward): Windows/Linux: Ctrl ←; macOS: Cmd ←Next step (forward): Windows/Linux: Ctrl →; macOS: Cmd →
