This question already has an answer here:

I try to make a backup script, but when i create a zip with the script, and use cd myzip it sais that it dosnt exitst even when i can see it on the server with FileZilla.

This is my script:

TIME=BACKUPMC-`date +%d-%m-%Y-%H:%M`.zip
DEST="/home/daixhosting/d1"
zip -r $TIME /home/daixhosting/d1

Does someone know what the cause can be?

marked as duplicate by A.B., Eric Carvalho, Mitch Aug 3 '15 at 6:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • When i try to unzip it, it cant locate the file, i can only see it, but cannot do anything with it. – Casper Rasmussen Aug 2 '15 at 15:32
  • what's the name of the file? – heemayl Aug 2 '15 at 15:47
  • Its as the script sais: BACKUPMC-02-08-2015-17:15.zip That was the time i runned the script – Casper Rasmussen Aug 2 '15 at 15:54
  • Try unzip BACKUPMC-02-08-2015-17:15.zip and then check.. – heemayl Aug 2 '15 at 17:08
  • @heemayl i can't do that couse it cannot find the file. – Casper Rasmussen Aug 2 '15 at 18:36

You have carriage return \r in the file names, as a result you are not being able to parse the files using usual manner.

To remove all the \r characters from the file names run the following command in bash from the directory containing the files :

for file in *; do mv -i "$file" "$(sed 's/\r//g'<<<"$file")"; done

Now all the files should not have \r in them , now you can zip them using usual manner e.g. :

zip -r foo.zip /home/foobar/spam/

Try changing the name of the zip file to a file name without the ":".

If that's not the problem, consider that the file could be corrupted. So, you'll try to repair it and maybe save a part of the information. Some way for that is, for example,

zip -F broke.zip --out pleasework.zip

or

zip -FF broke.zip --out pleasework.zip
  • i tried that at the sais that it can't find the zip fil. – Casper Rasmussen Aug 2 '15 at 18:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.