Concept Flow - gzip and gunzip
Start with file
Run gzip
File compressed to .gz
Run gunzip
File decompressed back
End
This flow shows compressing a file with gzip and then decompressing it with gunzip.
echo "Hello World" > file.txt
gzip file.txt
ls
gunzip file.txt.gz
ls| Step | Command | Action | File State | Output |
|---|---|---|---|---|
| 1 | echo "Hello World" > file.txt | Create file.txt with text | file.txt exists | |
| 2 | gzip file.txt | Compress file.txt to file.txt.gz and remove original | file.txt.gz exists, file.txt removed | |
| 3 | ls | List files | file.txt.gz exists | file.txt.gz |
| 4 | gunzip file.txt.gz | Decompress file.txt.gz to file.txt and remove .gz | file.txt exists, file.txt.gz removed | |
| 5 | ls | List files | file.txt exists | file.txt |
| File | Initial | After gzip | After gunzip |
|---|---|---|---|
| file.txt | exists | removed | exists |
| file.txt.gz | does not exist | exists | removed |
gzip compresses files by replacing the original with a .gz file. gunzip decompresses .gz files back to original and removes the .gz. Use gzip filename to compress and gunzip filename.gz to decompress. After gzip, original file is gone; after gunzip, original file returns. Check files with ls to see changes.
gzip command do in Linux?gzip command compresses files to save disk space..gz.data.txt but keep the original file?-k option tells gzip to keep the original file after compression.gzip -k data.txt compresses and keeps the original file.gzip -k report.txt gunzip report.txt.gz
gunzip file.txt but get an error saying "not in gzip format." What is the likely problem?log1.txt, log2.txt, and log3.txt. You want to compress all of them but keep the original files. Which command will do this correctly?gzip compresses files; log*.txt matches all log files.-k option keeps original files after compression.Pass the test and this pattern moves unknown