注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

PostgreSQL 中文网

 
 
 

日志

 
 

LINUX: grep 命令去空行  

2012-09-04 17:00:39|  分类: RHEL |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

 
 
       今天学习了 grep 命令一个小技巧,即 “去空行”, grep 命令能够非常方便地查看配置文件哪些参数被
修改了,今天测试了把,用来处理 PostgreSQL 的配置文件 postgresql.conf。


--1 查看 postgresql.conf 文件中被修改的参数

 [postgres@redhat6 pg_root]$ cat postgresql.conf | grep -v "^$" | grep -v "^#" 

                                        # (change requires restart)
                                        # (change requires restart)
                                        # (change requires restart)
                                        # (change requires restart)
listen_addresses = '*'          # what IP address(es) to listen on;
                                        # comma-separated list of addresses;
                                        # defaults to 'localhost'; use '*' for all
                                        # (change requires restart)
port = 1922                             # (change requires restart)
max_connections = 100           # (change requires restart)
                                        # (change requires restart)
                                        # (change requires restart)
                                        # (change requires restart)
                                        # (change requires restart)
                                        # 0 selects the system default
                                        # 0 selects the system default
                                        # 0 selects the system default
shared_buffers = 32MB                   # min 128kB
                                        # (change requires restart)
                                        # (change requires restart)
                                        # in kB, or -1 for no limit
                                        # (change requires restart)
wal_level = archive                     # minimal, archive, or hot_standby
                                        # (change requires restart)
                                        # off, local, remote_write, or on
                                        # supported by the operating system:
                                        #   open_datasync
                                        #   fdatasync (default on Linux)
                                        #   fsync
                                        #   fsync_writethrough
                                        #   open_sync
                                        # (change requires restart)
checkpoint_segments = 3         # in logfile segments, min 1, 16MB each
checkpoint_timeout = 2min               # range 30s-1h
checkpoint_completion_target = 0.5      # checkpoint target duration, 0.0 - 1.0
archive_mode = on               # allows archiving to be done
                                # (change requires restart)
archive_command = '/bin/date'           # command to use to archive a logfile segment

...

..省略部分

   
 备注:符号 ^ 表示匹配一行的开始; $ 表示匹配一行的结束; 所示 ^# 表示空行。
            因此去掉 postgresql.conf  中的空行,并且排除掉以 # 打头的行,即为已更改的配置文件参数。


--2 查看 postgreql.conf 中值为 "on" 的参数

 [postgres@redhat6 pg_root]$ cat postgresql.conf  | grep "= on$" | grep -v "^#"
log_checkpoints = on
log_connections = on
track_activities = on
   


--3 查看 postgreql.conf 中值为 "off" 的参数

 [postgres@redhat6 pg_root]$ cat postgresql.conf  | grep "= off$" | grep -v "^#"
log_disconnections = off

   


--4 附件 postgresql.conf

     本来想上传 postgresql.conf ,网易 blog 居然不支持上传 txt  格式文件,熟悉 postgresql 的朋友应该都知道这个

配置文件,这里就不上传了。

  评论这张
 
阅读(27863)| 评论(1)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2016