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

Use the crudini command of linux to manipulate ini files

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Editor to share with you the use of linux's crudini command to manipulate ini files. I hope you will gain a lot after reading this article. Let's discuss it together.

Crudini is a tool developed by P á draig Brady with Python to edit configuration files (that is, ini files). Crud is the abbreviation of the first letter of four words, namely create, read, update and delete, which is translated into Chinese as "addition, deletion, modification and search". This is the four most common ways to manipulate data. Some software configuration files are in ini format, such as php.ini. Such configuration files tend to be divided into several paragraphs. Paragraphs are identified in a format such as [default]. Specific configuration entries are in the form of "datadir=/var/lib/data".

Syntax format: crudini [parameters] [file]

Common parameters:

-- format=FMT is used by-- get. Select the output format. The format has sh,ini,lines--inplace locking and writing to the file, with fewer restrictions than the default replacement-- list is-- set and-- del, update the value of a list (collection)-- list-sep=STR uses custom characters instead of the default comma-- output=FILE writes the output to the file.' -"indicates standard output"-- verbose indicates whether changes have been made on the error output

Reference example:

Config_file represents the name of the file to be operated on, and section represents the part of the variable, such as the following configuration file:

[DEFAULT] user = admin passwd = admin port = 8088 [URL] client = 127.0.0.1 admin port 8088 admin = 127.0.0.1

Section represents [DEFAULT] and [URL] in the above configuration file, without brackets [] in the command, and param, such as user, passwd,client, and so on.

Add or update a variable:

[root@linuxcool] # crudini-- set config_file section parameter value

Update an existing variable:

[root@linuxcool] # crudini-- set-- existing config_file section parameter value

Delete a variable:

[root@linuxcool] # crudini-- del config_file section parameter

Delete a segment:

[root@linuxcool] # crudini-- del config_file section

Get a value:

[root@linuxcool] # crudini-- get config_file section parameter

Get a value that is not in the segment:

[root@linuxcool] # crudini-- get config_file''parameter

Get a segment:

[root@linuxcool] # crudini-- get config_file section

Merge the linuxcool.ini configuration file into linuxprobe.ini:

[root@linuxcool ~] # crudini-- merge linuxprobe.ini < linuxcool.ini after reading this article, I believe you have some understanding of using linux's crudini command to manipulate ini files. You want to know more about it. Welcome to follow the industry information channel. Thank you for reading!

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