[Linux] 壓縮/解壓縮指令集 – Compress/Uncompress

.tar (無壓縮)

  • 打包

    tar cvf OutputFile.tar.gz InputFile
    tar cvf OutputFile.tar.gz InputFile InputFile2 InputFile3
    
  • 解包

    tar xvf FileName.tar
    
  • 查看tar內文件不解壓縮

    tar -tvf FileName.tar
    
  • 進入目標資料夾 (打包不含路徑)

    tar cvf OutputFile.tar.gz -C InputFileWithPath .
    tar cvf OutputFile.tar.gz -C InputPath InputFile
    

.tar.gz

基本用法同上tar應用。

  • 壓縮

    tar zcvf OutputFile.tar.gz InputDir
    
  • 解壓縮

    tar zxvf FileName.tar.gz
    tar zxvf FileName.tar.gz -C Directory
    

zip

  • 壓縮

    zip OutputFile.zip InputFile
    zip OutputFile.zip InputFile InputFile2 InputFile3
    
    zip -r OutputFile.zip InputFile
    
  • 解壓縮

    unzip FileName.zip
    
  • 查看ZIP內文件不解壓縮

    zip -l FileName.zip
    

Leave a Reply

Your email address will not be published. Required fields are marked *