vi ~/.bashrc,增加一个function
svnlog(){
svn log "$@" | awk -f <(cat <<EOF
#!/usr/bin/awk -f # Convert the "svn log" output into a one liner format, which is easier to grep
# or use in scripts. Pipe "svn log" into this script # When we get a line that starts with a revision number, put the data in variables
/^r[-]+/ {
rev=\$
user=\$
date=\$
time=\$
lines=
} # Anything that isn't a revision line, a separator line or an empty line
# will be part of the commit message. Concatenate these into the comment variable
! (/^r[-+]/ || /^-+$/ || /^$/) {
comment = comment \$
} # With every separator line, output what we stored before and reset the comment variable
# To skip the first line we also check if we've already stored a revision
/^-+$/ && rev {
print rev " | " user " | " date " | " time " | " comment
comment = ""
}
EOF
)
}
awk正则表达式参考的是:https://gist.github.com/plexus/1485222
使用方法:svnlog -l 10