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.