Compress a Folder in UNIX & Linux via TAR & GZIP

In UNIX & Linux operating system, the GZIP is can be only compress a single file instead of a full folder. The TAR itself can archive multiple files but not able to compress the files. Manually, you need to TAR the files inside the folder first and then GZIP it. Please execute a below command to combine the TAR & GZIP a folder directly.

tar -cvzpf FILE-NAME.tar.gz /PATH-TO-DIRECTORY

Example

Scenario: You want to compress a folder name ABC in directory /usr/sap/ABC

# cd /usr/sap/ABC
# ls 
test1  test2  test3  test4  test5  test6  test7  test8  test9  test10
# tar -cvzpf ABC.tar.gz /usr/sap/ABC

You May Also Like

Leave a Reply?