Challenge - 5 Problems
File Download Automation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
What is the output of this wget command?
You run this command in a terminal:
What will be printed on the terminal?
wget -q --show-progress https://example.com/file.txt -O downloaded.txt && echo "Done"
What will be printed on the terminal?
Bash Scripting
wget -q --show-progress https://example.com/file.txt -O downloaded.txt && echo "Done"Attempts:
2 left
💡 Hint
The -q option means quiet, but --show-progress overrides some quietness.
✗ Incorrect
https://example.com/file.txt returns 404 Not Found, so wget exits non-zero and "Done" is not printed. -q suppresses error messages, and --show-progress does not show progress if the download fails immediately.
📝 Syntax
intermediate2:00remaining
Which script correctly downloads multiple files in a loop?
You want to download files from URLs stored in a file named urls.txt, one URL per line. Which script snippet correctly downloads each file using curl?
Attempts:
2 left
💡 Hint
Think about how to read lines safely from a file in bash.
✗ Incorrect
Option B uses a while read loop to read each line safely from the file. Option B splits on spaces which can break URLs with spaces. Option B is invalid syntax. Option B treats the filename as a URL.
🔧 Debug
advanced2:30remaining
Why does this script fail to download files correctly?
Consider this script:
It fails to download the first file. What is the problem?
urls=("http://site.com/file 1.txt" "http://site.com/file2.txt")
for url in "${urls[@]}"; do
curl -O "$url"
doneIt fails to download the first file. What is the problem?
Bash Scripting
urls=("http://site.com/file 1.txt" "http://site.com/file2.txt") for url in "${urls[@]}"; do curl -O "$url" done
Attempts:
2 left
💡 Hint
Spaces in URLs must be encoded as %20.
✗ Incorrect
curl fails because the URL contains a space character which is invalid in URLs. It should be encoded as %20 to work properly.
🚀 Application
advanced2:00remaining
How to automate retrying downloads on failure?
You want a bash script that tries to download a file with curl up to 3 times if it fails. Which snippet achieves this?
Attempts:
2 left
💡 Hint
Use a loop with a break on success.
✗ Incorrect
Option C tries up to 3 times and stops if curl succeeds. Option C tries sequentially but is less clear. Option C loops only if curl succeeds, so it breaks immediately. Option C tries only twice and no loop.
🧠 Conceptual
expert3:00remaining
What is the best way to download files securely in a script?
You want to automate file downloads in bash but ensure the files are not tampered with. Which approach is best?
Attempts:
2 left
💡 Hint
Think about verifying file integrity after download.
✗ Incorrect
Verifying the checksum ensures the file is exactly what you expect and not tampered with. Ignoring SSL or using HTTP is insecure.