Continue in sed

Written late in the afternoon in English

TIL: continue in sed(1) is really not n; but rather { p; d; } (at least in simple enough cases).

{
    # Let's construct a single long input line
    # from multiple short lines that fit better
    # on the web page.
    tr -d \\n <<-EOF
        207.46.13.105 - - [29/Jan/2020:17:23:25 +0200]
        "GET /cgi-bin/man-cgi?hier+7 HTTP/1.1"
        200 61152 "-" "Mozilla/5.0 (compatible;
        bingbot/2.0; +http://www.bing.com/bingbot.htm)"
        EOF
    echo
} |
sed -e '
    s/^[^"]*"//
    s/".*$//
    /^.* HTTP\/\([0-9]\.[0-9]\)$/ { s//\1/; p; d; }
    s/^.*$/0.9/
'

Add a comment