> file path"."/> > file path".">

Home>Article>Operation and Maintenance> How to edit files in centos

How to edit files in centos

WBOY
WBOY Original
2022-03-23 18:29:12 15725browse

How to edit files in centos: 1. Use vi and vim to open the specified file. The syntax is "vi/vim file name". After entering the document, click "i" or "o" to start file editing; 2. Use the append statement to edit directly after the file. The syntax is "echo edit content >> file path".

How to edit files in centos

The operating environment of this article: centos 7 system, Dell G3 computer.

How to edit files in centos

1. Use vi/vim to compile files.

Command vi/vim mysql.log, enter the document and click

i or o to edit the file.

The example is as follows:

Use the vi command to edit /etc/my.ini

If not, create a new file.

vi /etc/my.ini

Press i to enter the insert state to perform editing operations

Press the ESC key to jump to the command mode (the insert at the bottom disappears, enter the following command to perform the corresponding operation), then:

  • :q! Do not save the file and exit vi

  • :wq Save the file and exit vi

  • :w Save the file without exiting vi

  • :w file Save the modifications to file without exiting vi

  • :w! Forced Save without exiting vi

  • :wq! Force save the file and exit vi

2. Use append statement Edit

directly after the file. The example is as follows:

echo “nice to meet you">> /var/log/mysql/error.log

Recommended tutorial: "centos tutorial"

The above is the detailed content of How to edit files in centos. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn