Home >Operation and Maintenance >CentOS >CentOS common commands for viewing and editing files

CentOS common commands for viewing and editing files

藏色散人
藏色散人forward
2021-02-19 17:44:504568browse

The following tutorial column of centos will introduce you to the commonly used CentOS commands to view and edit files. I hope it will be helpful to friends in need!

CentOS common commands for viewing and editing files

cat:

1.cat file Viewing files

2.cat file -A to view all files

3. cat file -b to view non-blank lines and output line numbers

4. cat file -n to view all lines to output line numbers

5. cat file -s does not output multiple blank lines

vi:

1. vi file enters the file

2. Press [i] to enter insert mode. You can edit

3. Press [o] to insert a carriage return at the cursor and then edit

4. Press [x] to delete a character to the right of the cursor

5. Press [r] to replace the character where the cursor is.

6. [#dd] Delete the content from the current line to the # line (# represents a number)

7. [#yy 】Copy the characters in the line to

#5. Press ESC to exit the current mode

6. Press [:] to enter lastlinemode mode

Enter [q]: No Save and exit

Enter [wq]: Save and exit

Enter [q!]: Force exit (without saving)

Enter [wfilename]: Save as filename File

Enter [/]: search for characters

in the file

The above is the detailed content of CentOS common commands for viewing and editing files. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete