在一台机器上运行多个 Tomcat 的时候,需要修改 server.xml 中的好几个端口。
vim $CATALINA_HOME/conf/server.xml

在 VIM 中用下面的替换可以迅速的给每个端口加1,也就是把 8080 变成了 8081,等等

:%s/\([pP]ort\)=”\([0-9]\+\)”/\=printf(“%s=\”%d\””,submatch(1),submatch(2)+1)/g

或者用下面的替换可以迅速的给每个端口前增加一个数字,下面的例子是增加 4,也就是把 8080 变成了 48080,等等

:%s/\([pP]ort\)=”\([0-9]\+\)”/\1=”4\2″/g

Leave a Reply

Your email address will not be published.

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

This site uses Akismet to reduce spam. Learn how your comment data is processed.