wget -O: Set the Output Filename
wget -O <file> saves the download under a name you control rather than the one derived from the URL.
In a pipeline you usually want a deterministic local name. -O fixes the output path so later steps can reference it without parsing the URL.
What it does
wget -O <file> writes the retrieved document to the named file. With -O - it writes to stdout, which lets you pipe a download into another command. Note -O concatenates everything into one file, so it is not for recursive downloads.
Common usage
wget -O app.tar.gz https://example.com/releases/app-1.2.0.tar.gz
# write to stdout and pipe
wget -O - https://example.com/list.txt | sort
# combine with quiet for clean logs
wget -q -O kubectl https://dl.k8s.io/release/v1.30.0/bin/linux/amd64/kubectlOptions
| Flag | What it does |
|---|---|
| -O <file> | Write the download to this filename |
| -O - | Write to stdout (for piping) |
| -q | Quiet; suppress progress and messages |
| -P <dir> | Set the directory prefix instead of naming the file |
In CI
Pick an explicit output name with -O so downstream steps are not coupled to the URL path. Pair it with -q to keep the job log readable; the progress bar is noise in non-interactive runs.
Common errors in CI
No such file or directory means the parent directory in the -O path does not exist; wget does not create intermediate directories, so mkdir -p first or use -P. If the file is created but empty, the server likely returned an error body and wget still wrote it; check the exit code and the HTTP status in the log.