我的输出值不会换行
来源:9-8 利用sed查找文件内容(下)
CherryJ
2019-12-18
老师我输出的值没有换行,导致所有的结果都是1 这个怎么解决
写的都是正确的
输出结果都是1 ,打印items 发现没有换行
写回答
3回答
-
把源代码直接贴上来,包括你的mysql配置文件,我来看一下,这样看不确定哪里有问题哈
032019-12-19 -
CherryJ
提问者
2019-12-18
[client] #password = your_password port = 3306 socket = /var/lib/mysql/mysql.sock # Here follows entries for some specific programs # The MySQL server [mysqld] port = 3306 socket = /var/lib/mysql/mysql.sock skip-external-locking key_buffer_size = 384M max_allowed_packet = 1M table_open_cache = 512 sort_buffer_size = 2M read_buffer_size = 2M read_rnd_buffer_size = 8M myisam_sort_buffer_size = 64M thread_cache_size = 8 query_cache_size = 32M
00 -
CherryJ
提问者
2019-12-18
#! /bin/bash\ # FILE_NAME=/usr/share/mysql/my-huge.cnf function get_all_segment { echo "` sed -n '/\[.*\]/p' $FILE_NAME | sed -e 's/\[//g' -e 's/\]//g' `" } #for seg in `get_all_segment` #do # echo " segment: $seg" #done function count_items_in_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` done echo $index } #echo `count_items_in_segment mysqldump` #count=`count_items_in_segment mysqldump` #echo $count number=0 for segment in `get_all_segment` do number=`expr $number + 1` itc=`count_items_in_segment $segment` echo "$number: $segment $itc" done
00
相似问题