Linux wget BASH script

Posted on 2004-09-30
Last Modified: 2008-02-01
Hello all,

I'm trying to write a script to wget files in a url list then when done echo the successful downloads / total downloads attempted. Any ideas on this?
Question by:GR999
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 44

Accepted Solution

Karl Heinz Kremer earned 300 total points
ID: 12195670
Try this:


url_list="http://url1 http://url2"


for i in $url_list; do
        wget -q $i
        if [ $res -eq 0 ] ; then
                (( success++ ))
                success_urls="$success_urls $i"
        if [ $res -ne 0 ] ; then
                (( failed++ ))
                failed_urls="$failed_urls $i"

echo "$success successful downloads:"
for i in $success_urls ; do
        echo $i
echo "$failed failed downloads"
for i in $failed_urls ; do
        echo $i
# end of script

Set the url_list variable to the URLs you want to download. You can of course also change the wget parameters.

Author Comment

ID: 12202656
Wow nice job! Works great just modified the url list stuff. Much better than what i had originally as I am fairly new to scripting. This is what I had started with...bear with me I only have a very small grasp of programming:



echo "What file should I use?"
read urllist

for i in $(cat $urllist); do
wget $i
 if $? > 0
 then PKGS=$[$PKGS + 1]
 elif $? = 0
        SAVED=$[$SAVED + 1]
        PKGS=$[$PKGS + 1]


echo "The files successfully downloaded is $SAVED/$PKGS "

##End Script

This would do its job, but the last echo would not be accurate. Anyway I appreciate your help, thnx alot!!


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CentOS 6.6 Port opening question 1 139
Install Apache on a Mac with Homebrew | Apache Config Issues 1 234
mysql server issue in linux server 5 68
centOS 7 GUI is now showing. 20 1,913
Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question