Skip to content

Instantly share code, notes, and snippets.

@timmc
Last active November 16, 2022 03:23
Show Gist options
  • Save timmc/1524e73039238ea4a94c106f8f71f90f to your computer and use it in GitHub Desktop.
Save timmc/1524e73039238ea4a94c106f8f71f90f to your computer and use it in GitHub Desktop.

Revisions

  1. timmc revised this gist Nov 16, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion split headers.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    all_output="$(curl -isS https://www.spidersge.org/)"

    status=$(echo "$all_output" | head -n1 | grep -o -P '\s+[0-9]+\s*' | tr -dc 0-9)
    status=$(echo "$all_output" | grep -Po '\s[0-9]{3}\s' | head -n1 | tr -dc 0-9)
    echo "Status is [$status]"

    body="$(echo "$all_output" | sed -ne $'/^\r$/,$p' | tail -n+2)"
  2. timmc revised this gist Nov 16, 2022. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions split headers.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    #!/bin/bash

    all_output="$(curl -isS https://www.spidersge.org/)"

    status=$(echo "$all_output" | head -n1 | grep -o -P '\s+[0-9]+\s*' | tr -dc 0-9)
    echo "Status is [$status]"

    body="$(echo "$all_output" | sed -ne $'/^\r$/,$p' | tail -n+2)"
    echo "Body is [$body]"
  3. timmc created this gist Nov 16, 2022.
    9 changes: 9 additions & 0 deletions tail and head.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    #!/bin/bash

    all_out="$(curl -sS https://www.spidersge.org/ -w '%{http_code}')"

    status="$(echo "$all_out" | tail -c4)"
    echo "Status is [$status]"

    body="$(echo "$all_out" | head -c-4)"
    echo "Body is [$body]"