By default zip unzip are not installed on CentOS, so we have to install it
[root@vpshelpdesk]# yum install zip Loaded plugins: fastestmirror Setting up Install Process [root@vpshelpdesk]# yum install unzip Loaded plugins: fastestmirror Setting up Install Process
Compress files error.log to error.zip in current directory
[root@vpshelpdesk]zip error.zip error.log
Compress entire files, folder but not including all subdirectories to data.zip in current directory
[root@vpshelpdesk]#zip data.zip *
Compress entire files, folder, all subdirectories and hidden files to data.zip
[root@vpshelpdesk]#zip -r data.zip .* -x "../*"
To uncompress or extract data.zip
[root@vpshelpdesk]#unzip data.zip
You can also test data.zip, printing only a summary message indicating whether the archive is OK or not:
[root@vpshelpdesk]#unzip -tq data.zip
To extract the file called file.txt from data.zip:
[root@vpshelpdesk]#unzip data.zip file.txt
To extract all files into the /tmp directory:
[root@vpshelpdesk]#unzip data.zip -d /tmp
To list all files from data.zip:
[root@vpshelpdesk]#unzip -l data.zip
To move all folder and files
#mv /sourcefolder/{,.[^.]}* /destinationfolder/