In my shell script I am using the zip command to zip the log files. The zip file is password protected. But there is a dicey.
I want the output as:
1) All files should be zipped including sub-directories' files
2) All files (individually) should be Password protected (may be common or different)
3) User should feed the password as input just once.
Condition 1 is met. But in Condition2 the sub-directory files are not password protected.Rather the sub-directory is password protected.
I used
zip -r -9 -m -P password file_name.zip *
Here password I handled in variable (condition 3) and without any interference zip command works. I tried using zip command option -e (as zip -r -e ...). But it prompts for password twice which is not recommended. Or is there any way to get the password from user as input and feed the same in run time when it prompts for Password while using -e option?
cd /path/to/files
tar cvf /tmp/myarchive.tar .
zip -9 -P password zipfilename.zip /tmp/myarchive.tar
to extract:
unzip -P password zipfilename.zip
cd /path/to/restore/directory
# list the archive to find one file
tar tf /tmp/myarchive.tar | more
# restore one file
tar xvf /tmp/myarchive.tar [EXACT filename]
# restore the whole archive
tar xvf /tmp/myarchive.tar
Point is: you should be using tar, then compressing.
Thanks for the response, Jim. As you suggested, it worked.
But let know :
1) if we can use -e as option and the password can be fetched from any file and given as input in run time scenario?