• 〖Linux〗svn log 每个日志记录只显示一行的方法


    vi ~/.bashrc,增加一个function

     1 svnlog(){
     2     svn log "$@" | awk -f <(cat <<EOF
     3 #!/usr/bin/awk -f
     4 
     5 # Convert the "svn log" output into a one liner format, which is easier to grep
     6 # or use in scripts. Pipe "svn log" into this script
     7 
     8 # When we get a line that starts with a revision number, put the data in variables
     9 /^r[0-9]+/ {
    10     rev=$1
    11     user=$3
    12     date=$5
    13     time=$6
    14     lines=13
    15 }
    16 
    17 # Anything that isn't a revision line, a separator line or an empty line
    18 # will be part of the commit message. Concatenate these into the comment variable
    19 ! (/^r[0-9+]/ || /^-+$/ || /^$/) {
    20   comment = comment $0
    21 }
    22 
    23 # With every separator line, output what we stored before and reset the comment variable
    24 # To skip the first line we also check if we've already stored a revision
    25 /^-+$/ && rev {
    26    print rev " | " user " | " date " | " time " | " comment
    27    comment = ""
    28 }
    29 EOF
    30 )
    31 }

     awk正则表达式参考的是:https://gist.github.com/plexus/1485222

    使用方法:svnlog -l 10

  • 相关阅读:
    pexpect模块
    Python正则表达式
    telnetlib
    paramiko
    threadpool和Queue
    logging
    Python异常
    Python迭代器
    程序员工资那么高,却从不炫富?网友回复让人“笑喷了”!
    小白到web前端工程师需要学习哪些知识?
  • 原文地址:https://www.cnblogs.com/scue/p/4379669.html
Copyright © 2020-2023  润新知