Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
WangYan
V2EX  ›  Linux

Shell中如何获得最新版本的PHP?

  •  
  •   WangYan ·
    wangyan · Sep 10, 2012 · 4127 views
    This topic created in 5020 days ago, the information mentioned may be changed or developed.
    我需要在Shell中获得最新PHP版本号,然后检查服务器是否需要升级。

    比如 Apache 提供的下载是 http://www.apache.org/dist/httpd/ ,它将所有版本都列出来了,我可以通过elinks和awk轻松提取最新版本号,但是php要怎样做呢?
    3 replies    1970-01-01 08:00:00 +08:00
    robhsiao
        1
    robhsiao  
       Sep 10, 2012
    curl -s http://php.net/downloads.php | grep 'Current stable' | perl -nle 'print $1 if m/(\d+\.\d+\.\d+)/'
    WangYan
        2
    WangYan  
    OP
       Sep 10, 2012
    感谢 @robhsiao

    是我愚钝了,没想到用curl。segmentfault.com 中的“大盗贼”给出了我更喜欢的答案。

    curl -s http://www.php.net/downloads.php |grep "Current stable" |awk '{print $3}'
    cute
        3
    cute  
       Sep 11, 2012
    curl -s http://www.php.net/downloads.php|awk '/Current stable/{print $3}'
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   928 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 21:36 · PVG 05:36 · LAX 14:36 · JFK 17:36
    ♥ Do have faith in what you're doing.