Linux 下去除空白行的方法

背景:
有时当进行某些配置文件的查看时,去除注释(如:"#"),但之后还会发现中间也许会有好多空行,
所以小结一下去除空行的方法。

#pwd
/usr/local/kafka/config

方法1:
#cat server.properties | grep -v ^#|uniq | tr -s '\n'
方法2:

#cat server.properties | grep -v ^#|uniq | grep -v "^$"
方法3:
#cat server.properties | grep -v ^#|uniq | awk '{if($0!="")print}'
等同于:
#cat server.properties | grep -v ^#|uniq | awk '{if(length !=0) print $0}'

方法4:
# cat server.properties | grep -v ^#|uniq | sed '/^$/d'
示例:
broker.id=1
host.name=10.19.85.149
auto.create.topics.enable=true
delete.topic.enable = true
message.max.bytes=200000000
replica.fetch.max.bytes=204857600
fetch.message.max.bytes=204857600
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=1048576000
log.dirs=/data/kafka/log
num.partitions=3
num.recovery.threads.per.data.dir=1
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=10.19.85.149:2181,10.19.15.103:2181,10.19.189.221:2181
zookeeper.connection.timeout.ms=6000
group.initial.rebalance.delay.ms=0

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值