找回密码
 注册
查看: 3823|回复: 2

使用grep过滤空格和注释行

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2017-10-9 10:19:50 | 显示全部楼层 |阅读模式
过滤空格和注释行4 S" E9 a: e8 g8 c. c
# cat 文件  | grep -v "#" |grep -v "^$"8 h- E1 c$ b1 ^' |; m, U
$ r, O' y2 R. }# f6 f
例如:
$ t1 }$ [7 Y  K* e. \& m% d# cat /etc/keystone/keystone.conf  | grep -v "#" |grep -v "^$"" q; x$ |  I4 S) T
[DEFAULT]
: E% T) }4 j  G% k; a2 Z6 F[assignment]
; j( F/ |* K! I5 l[auth]2 r" ~9 Q5 F. s6 F* e
[cache]: x+ g( j, a3 m4 A9 Y
[catalog]; V8 {' Z  @# i. E* ]
[cors]
! n! j" x) X) {, p$ S6 o( U) F[credential]
4 C1 c6 x4 m- k1 g( ^! h9 C/ T[database]7 x0 G4 M9 j5 u0 {3 G3 w% t
[domain_config]* B3 {" `) |3 L- z- d
[endpoint_filter]2 F8 {. M( a$ \' [
[endpoint_policy]9 ~& I8 |' s# e0 ^- K! S
[eventlet_server]& N+ E' W- E& \
[federation]7 Q7 o2 ]! B! P5 R
[fernet_tokens]
' B" H4 F2 S: b# B! ][healthcheck]
* D1 N$ f  ^  R( B6 @[identity]
5 c6 H- W. z2 M4 ^[identity_mapping]9 Z  l, s3 w* e% |* `1 f% d, r# g
[ldap]) {% ~* D0 K  A/ U( ?) c; e! n# ?
[matchmaker_redis]$ b) t3 [$ D, `* V* D" h: y/ h9 W5 Y
[memcache]' v! @( r6 Y8 v$ ~1 f/ T
[oauth1]
" w+ E8 ]' j# J% A2 ~[oslo_messaging_amqp]8 c8 p! Q+ B7 i7 c
[oslo_messaging_kafka]
2 p3 Q+ [  F4 s8 W# z) p/ ^[oslo_messaging_notifications]0 I3 b9 {) `1 A2 b, o8 x4 n& g
[oslo_messaging_rabbit]
" Q) ]) O7 F0 M2 q. x8 \7 r[oslo_messaging_zmq]
# o- j" _1 V, B8 k" V! G; u( K[oslo_middleware]
' c/ k' P) Y. Q5 M+ A* Z3 Z! a[oslo_policy]. q1 E' n( F# C$ w9 A, t# d2 c
[paste_deploy]
+ e& C" D  M! ^* k  c! Y) r[policy]5 I/ {5 v& {8 U7 m. _2 l  l
[profiler]& s, b$ ?* o+ ]) z/ u5 T
[resource]
/ n8 m# @% |" @% s[revoke]8 v" q2 k# j; J; S* F9 L
[role]2 o. i. m& g' B- W( _: [) {7 ^& W# u
[saml]7 N, v0 \0 s, q3 a9 |
[security_compliance]5 y6 Y$ f9 A; F2 V8 I- U
[shadow_users]
+ b) ?5 W% }; x2 ~& a9 E# k[signing]
& P# g2 ^" d8 }! _1 J* A" L[token]
0 T0 \$ C5 {. ^[tokenless_auth]: Z% D+ u8 E* ~
[trust]
! R+ i1 Y0 V1 t0 s2 {2 a
5 j; n3 |( O1 `# j3 F" b9 ]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2017-10-9 10:20:45 | 显示全部楼层
用awk命令
0 N0 j% B# T2 V# p* scat 文件名 |awk ‘{if($0!=”")print}': K3 R5 V% Y0 b8 N# m' f$ N1 V
cat 文件名 |awk ‘{if(length !=0) print $0}'

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2017-10-10 09:45:00 | 显示全部楼层
# cat /etc/glance/glance-api.conf |grep -v "#" |grep -v "^$"( s: `% o. S/ q; s, V
[DEFAULT]
" D" P) m& O! F5 _: R3 Z[cors]
/ J7 N  M7 K1 c# A7 l, r* a[database]" k& i- u; P1 j( E& r6 J3 ]3 ]
[glance_store]
$ u7 b' c5 H* h4 k1 m[image_format]
5 A: O9 }$ M6 c[keystone_authtoken]
2 f+ [- c* G* q' b5 W[matchmaker_redis]) i$ Z, p$ s0 p7 K% ^. e
[oslo_concurrency]1 [) ?; q  f4 z
[oslo_messaging_amqp]& i: _6 B* i, V, T* I
[oslo_messaging_kafka]3 ^1 [* Q/ a* v6 I
[oslo_messaging_notifications]0 J6 J6 ^' a, V/ A% c8 \: b
[oslo_messaging_rabbit]
3 w; v: m# }1 R& D" p& x[oslo_messaging_zmq]( ?7 _! m5 A" P: s8 q
[oslo_middleware]
9 c! A3 L7 F6 Y, a) w% A& k[oslo_policy]
' Q. Y: _* e% T( Y[paste_deploy]
9 v% \9 M( P& o- \- e  l  }[profiler]
" v9 @; A9 G" \1 H/ w1 y[store_type_location_strategy]
; t, H( z- T1 c1 T6 N0 o[task]
; Y% y( [: a* ]  [+ J1 Z* n/ W[taskflow_executor]
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 01:55 , Processed in 0.023263 second(s), 23 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表