Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The usage of vim and shell in Linux

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "the usage of vim and shell in Linux". In daily operation, I believe that many people have doubts about the usage of vim and shell in Linux. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about the usage of vim and shell in Linux! Next, please follow the editor to study!

In the Linux system, everything is a file, and the configuration service is actually modifying the parameters of its configuration file, and editing documents is indispensable in daily files, which is inseparable from vim. The reason why vim is favored by manufacturers and recognized by users is that there are three modes in the vim editor:

Command mode, control cursor, perform various operations on text

Input mode, text entry

Last line mode, save or exit the document, set up the editing environment

Every time you enter vim, the default is command mode, and the commands commonly used in vim are:

Dd: delete (cut) the entire line of the cursor

5dd: delete (cut) 5 lines where the cursor begins

Yy: copies the entire line where the cursor is located

5yy: copy the cursor on 5 lines

N: show search navigate to the next string

N: show search navigate to the previous string

U: undo the previous step

P: paste the data from the previous dd/yy behind the cursor

The last line mode is mainly used to save and exit files, and the common commands are:

: w

: q

: q!

: wq!

: set nu

: Set nonu

Command

: integer

: s/a/b

: s/a/b/g

:% s/a/b/g

:? String

: / string

As a communication medium between users and Linux system, shell terminal interpreter not only supports various variables and parameters, but also provides programming structure features unique to high-level languages such as loops and branches. Shell script commands work in two ways.

Interactive: execute immediately each time

Batch processing: one-time execution by shell

[root@linux ~] # vim example.shallows for Example BY linux.compwdls-A1

The script statement on the first line: #! Originally told the system which shell interpreter to use to execute the script

The comment message of the second line: # originally introduced all kinds of information

Three or four lines are Linux commands.

Judging the user's parameters is also a very important information.

-d: whether the file is a directory type

-e: whether the file exists

-f: whether it is a general document

-r: whether you have permission to read

-w: whether you have permission to write

-x: whether you have permission to execute

Flow control statement

If conditional then Command else Command fi

Multi-branch structure

If conditional then Command elif conditional then Command else Command fi

For conditional cycle

For variable name in value list do command done

While conditional loop statement

While conditional do Command done

Case conditional statement

Case variable value in mode 1) command 1; mode 2) command 2. This is the end of the study on "the use of vim and shell in Linux" with the default command esac. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report