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