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 number of my Shell study notes the number of configuration entries in the Mysql profile

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

Share

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

* this script comes from Mujia.com, and the copyright belongs to the original author *

Purpose of the script: query the number of configuration entries for a configuration item (such as [mysqld]) in the Mysql configuration file my.cnf and output it.

The specific script is as follows:

# *

# Author: tomshen

# QQ: × × ×

# Date: 2019-10-14

# Description: The test script

# Copyright (C): 2019 All rights reserved

# *

# output the name of each configuration segment of the my.cnf configuration file, and the number of configuration items for each configuration segment

FILE_NAME=/etc/my.cnf

Function get_all_segment

{

# get all segments

Declare-a mysql_array=$ (sed-n'/ [. *] / p'$FILE_NAME | sed-e's / [/ / g' | sed-e's /] / / g')

For var1 in ${mysql_array [@]}

Do

Echo "$var1"

Done

Unset var1

Unset mysql_aeeay

}

Function count_items_in_segment

{

# get the number of lines of the configuration entry for each configuration segment

Items=$ (sed-n "/\ [$1\] /, /\ [. *] / p" $FILE_NAME | grep-v ^ # | grep-v ^ $| grep-v "\ [. *\]") index=0 for item in $items do index= `expr $index + 1`expr $index

}

Number=0

For segment in get_all_segment

Do

Number=expr $number + 1

Items_count=count_items_in_segment $segment

Echo "$number. Configuration items: $segment configuration entries: $items_count"

Done

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