0

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?

5
  • 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, 2013 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. Jan 31, 2013 at 13:03
  • your command makes no sense. What are you trying to accomplish? Read the manual.
    – sivann
    Jan 31, 2013 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, 2013 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, 2013 at 9:43

0

You must log in to answer this question.

Browse other questions tagged .