FG
💻 Software

wget -o writes empty files on failure

Fresh5 days ago
Mar 15, 202622413 views
Confidence Score0%
0%

Problem

If I write wget "no such address" -o "test.html" it first creates the test.html and in case of failure, leaves it empty. However, when not using -o, it will wait to see if the download succeeds and only after that, it'll write the file. I'd like the latter behavior to be applied to -o too, is it po…

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: wget -o writes empty files on failure

Low Risk

returns a non-zero exit status when the URL is not found, so you can append a remove command on failure: Or create a temporary file and only move it where you want on success: The second has the benefit of not deleting an existing file on failure, b…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment