Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using wget command with the if like this:

if (wget -O file)

If the file is not present it creates and empty file, how can stop this from happening?

What are the alternatives to remove this?

share|improve this question
1  
You could just use wget -O file || rm file. Error responses from the server cause wget to return a non-zero exit code. –  Daniel Beck Jan 31 '13 at 12:47
    
You should say what shell you are using (bash/ksh etc.). Also have you read the wget man page ... it's very good, I'd be surprised if there wasn't some help. –  Peter Jenkins Jan 31 '13 at 13:03
    
your command makes no sense. What are you trying to accomplish? Read the manual. –  sivann Jan 31 '13 at 13:07
    
Let me explain, the command i am using is : if (wget -O /path/somefile.tar.gz $REPO_URL), here i am trying to check if somefle.tar.gz is present in my repository and if it is present then download it, now it works well if the file is present however if the file is not present then it creates an empty file "somefile.tar.gz" which i do not want...I want to prevent the creation of empty file.. –  user194263 Feb 1 '13 at 9:30
    
Hi Daniel, I tried with your suggestion earlier, however as i am using it within if it always evaluates to true and which i dont want..it should not go into the loop if the file is not present. –  user194263 Feb 1 '13 at 9:43
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.