# print from a compressed .gz to a txt file



## ccc (Aug 16, 2010)

hi

Howto print from a compressed .gz to a txt file, to show names of all directories and their size?


----------



## Andres (Aug 16, 2010)

You mean a tarball, since gzip can only hold a single file.


```
bsdtar tf foo.tar.gz > textfile
```


----------



## ccc (Aug 16, 2010)

thx, but there is a file.gz and not file.tar.gz file.


----------



## SirDice (Aug 16, 2010)

zcat(1) and/or bzcat(1)


----------



## phoenix (Aug 16, 2010)

And, for searching inside compressed files, as that's usually the next question, there's also zgrep(1) and bzgrep(1).


----------



## shitson (Aug 17, 2010)

ccc how is the data inside the .gz file structured? Could you provide a snippet of the output?


----------



## graudeejs (Aug 17, 2010)

It's simply compressed file, not archive full of files


----------



## ccc (Aug 17, 2010)

shitson said:
			
		

> ccc how is the data inside the .gz file structured? Could you provide a snippet of the output?


Sorry, but howto get snippet of the output?


----------



## shitson (Aug 17, 2010)

This file with the .gz extension, inside that compressed file - Originally what type of file was it?

You could try the following (replace filename.gz, with the name of your file)


```
zcat filename.gz > filename.txt
```


----------

