Reputation: 33
I am not sure why I am getting this output as I believe I am hopefully doing it correctly. I ran this script a few hours ago just testing some things and it worked just fine I had thought. I was able to zip the target with no errors.
The current directory is the proper folder containing the target file. The script is as follows:
#! /usr/bin/bash
echo Zipping Backup
zip -r "backup-$(date +"%D-%H-%M-%S").zip" test
There is just a simple empty folder in the directory named test. Here is the exact output running this script:
Zipping Backup
zip I/O error: No such file or directory
zip error: Could not create output file (backup-05/11/20-20-15-04.zip)
Wondering what sort of novice thing I may be overlooking here.
Upvotes: 2
Views: 4173
Reputation: 94435
backup-05/11/20-20-15-04.zip
The problem is obviously in slashes which are path separators. There is no directory backup-05/11/
hence the error. Fix your format:
date +"%Y-%m-%d-%H-%M-%S"
without slashes.
Upvotes: 2