Linux gzipGzip (GNU zip) is a compressing tool, which is used to truncate the file size. By default original file will be replaced by the compressed file ending with extension (.gz). To decompress a file you can use gunzip command and your original file will be back. Syntax: Example: Look at the above snapshot, the gzip command has compressed the files 'file1.txt' and 'file2.txt'. Compressed files are shown with the extension (.gz). While gunzip command has decompressed the same files and extension (.gz) is removed. gzip optionsCompressing Multi Files Together If you want to compress more than one file together, you can use 'cat' and gzip command with pipe command. Syntax: Example: Look at the above snapshot, both the files ' file1.txt' and 'file2.txt' are compressed as 'final.gz'. gzip -lThe 'gzip -l' command tells about the compression ratio or how much the original file has compressed. Syntax: Example: Look at the above snapshot, command "gzip -l final.gz jtp.txt.gz" shows the ratio of both the files. How To Compress A DirectoryThe gzip command will not be able to compress a directory because it can only compress a single file. To compress a directory you have to use 'tar' command. Hyphen (-) is not mandatory in 'tar' command. 'c' is to create, 'v' is for verbose, to display output, 'f' to mention destination of your output file, 'z' for specifying compress with gzip. Syntax: OR Example: Look at the above snapshot, directory 'office' is compressed with 'tar' command. Next TopicLinux AWK Command |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India