# bash script to download the latest release asset of any GitHub repo (e.g., llama.cpp)

> Source: <https://gist.github.com/benardayim/c498fb39bffff874bb8935f5901a0976>
> Published: 2026-07-13 19:55:00+00:00

| #!/usr/bin/env bash | |
| set -euo pipefail | |
| REPO="ggml-org/llama.cpp" | |
| PATTERN='https://[^"]*llama-b[0-9]+-bin-win-cuda-12\.4-x64\.zip' | |
| API_URL="https://api.github.com/repos/$REPO/releases/latest" | |
| DOWNLOAD_URL=$(curl -s "$API_URL" | grep -oE "$PATTERN" | head -1) | |
| if [ -z "$DOWNLOAD_URL" ]; then | |
| echo "Error: No asset matching '$PATTERN' found in latest release of $REPO" >&2 | |
| exit 1 | |
| fi | |
| FILENAME=$(basename "$DOWNLOAD_URL") | |
| DIRNAME="${FILENAME%.*}" | |
| echo "Downloading $FILENAME ..." | |
| curl -# -L "$DOWNLOAD_URL" -o "$FILENAME" | |
| echo "Extracting to $DIRNAME/" | |
| unzip -q "$FILENAME" -d "$DIRNAME" | |
| echo "Removing $FILENAME" | |
| rm "$FILENAME" | |
| echo "Done! Files in: $DIRNAME/" |
