How can I view the contents of tar.gz file without extracting from the command-line?
up vote
202
down vote
favorite
I want to see the contents (list of files and folders) of an archive, for example a tar.gz file without extracting it.
Are there any methods for doing that?
command-line
add a comment |
up vote
202
down vote
favorite
I want to see the contents (list of files and folders) of an archive, for example a tar.gz file without extracting it.
Are there any methods for doing that?
command-line
Tryman tar...
– Reinier Post
Jun 9 '17 at 13:55
add a comment |
up vote
202
down vote
favorite
up vote
202
down vote
favorite
I want to see the contents (list of files and folders) of an archive, for example a tar.gz file without extracting it.
Are there any methods for doing that?
command-line
I want to see the contents (list of files and folders) of an archive, for example a tar.gz file without extracting it.
Are there any methods for doing that?
command-line
command-line
edited Mar 30 '15 at 17:13
terdon♦
63.1k12132209
63.1k12132209
asked Dec 19 '13 at 5:46
Avinash Raj
50.9k41165210
50.9k41165210
Tryman tar...
– Reinier Post
Jun 9 '17 at 13:55
add a comment |
Tryman tar...
– Reinier Post
Jun 9 '17 at 13:55
Try
man tar ...– Reinier Post
Jun 9 '17 at 13:55
Try
man tar ...– Reinier Post
Jun 9 '17 at 13:55
add a comment |
10 Answers
10
active
oldest
votes
up vote
222
down vote
accepted
Run the below command in the terminal to see the contents of a tar.gz file without extracting it:
tar -tf filename.tar.gz

1
does all these examples to look inside compressed file works on other types of format too. like zip , rar , tar etc. ?
– Ciasto piekarz
Aug 4 '15 at 11:23
1
tar -tvf xxx.tgzthis would also show detail properties of files.
– Eric Wang
Mar 21 '17 at 2:10
3
pipe it totreeto see a tree viewtar -tf filename.tar.gz | tree
– blockloop
Apr 6 '17 at 15:28
For zip / rar useunzip -l/unrar -l
– RoVo
Jun 9 '17 at 13:55
add a comment |
up vote
99
down vote
You can also use vim
vim filename.tar.gz
7
This is awesome. You can also see the contents of the files!
– Nico
Oct 21 '14 at 13:24
1
Or use Ex editor:ex +%p foo.tar.gz.
– kenorb
Jul 23 '15 at 14:33
@Nico How do you use this to see the contents of a file within the tgz?
– 1252748
Dec 14 '16 at 19:15
1
When you open de file with vim (vim file.tar.gz) it says "Select a file with cursor and press ENTER". You do just that, move the cursor over a file and press ENTER.
– Nico
Dec 15 '16 at 19:56
2
With huge archive you just have to be patient. It can be very long to load folder structure. :-)
– Hugo H
Jul 27 '17 at 17:03
|
show 3 more comments
up vote
36
down vote
less can also open gz-compressed and uncompressed tar archives. It gives you a lovely ls -l style output too:
$ less ~/src/compiz_0.9.7.8-0ubuntu1.6.debian.tar.gz
drwxrwxr-x 0/0 0 2012-09-21 11:41 debian/
drwxrwxr-x 0/0 0 2012-08-09 13:32 debian/source/
-rw-rw-r-- 0/0 12 2012-08-09 13:32 debian/source/format
-rw-rw-r-- 0/0 25 2012-08-09 13:32 debian/libdecoration0-dev.docs
-rw-rw-r-- 0/0 25 2012-08-09 13:32 debian/compiz-dev.docs
-rw-rw-r-- 0/0 347 2012-08-09 13:32 debian/compiz-core.install
-rw-rw-r-- 0/0 125 2012-08-09 13:32 debian/libdecoration0-dev.install
...
And because it's less, you can scroll through it, search it, etc. However it fails miserably with other compression algorithms (in my experience).
3
Didn't work for me. Displayed as a binary file.
– JeromeJ
Dec 10 '17 at 16:31
1
You sure you don't have analiaswith special options forlessthat you're not showing here? I just tried that to see, but it didn't work. I don't have any aliases setup forless.
– code_dredd
Jul 20 at 22:14
add a comment |
up vote
32
down vote
You could use the z command: zcat, zless, zgrep.
To view a files content use:
zcat file.gz
To grep something use:
zgrep test file.gz
To check difference between files use:
zdiff file1.gz file2.gz
These are just a few example, there are many more.
add a comment |
up vote
9
down vote
Well, that depends on the file. Most (de)compression programs have a flag that lists an archive's contents.
tar/tar.gz/tgz/tar.xz/tar.bz2/tbzfiles
$ tar tf foo.tgz
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/subdir2/
dir1/subdir2/file
dir2/
zipfiles
$ zip -sf foo.zip
Archive contains:
dir1/
dir2/
dir1/subdir1/
dir1/subdir1/file
dir1/subdir2/
dir1/subdir2/file
Total 6 entries (0 bytes)
7zipfiles
$ 7z l foo.7z
7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
p7zip Version 9.20 (locale=en_US.utf8,Utf16=on,HugeFiles=on,4 CPUs)
Listing archive: foo.7z
--
Path = foo.7z
Type = 7z
Solid = -
Blocks = 0
Physical Size = 168
Headers Size = 168
Date Time Attr Size Compressed Name
------------------- ----- ------------ ------------ ------------------------
2015-03-30 19:00:07 ....A 0 0 dir1/subdir1/file
2015-03-30 19:00:07 ....A 0 0 dir1/subdir2/file
2015-03-30 19:07:32 D.... 0 0 dir2
2015-03-30 19:00:07 D.... 0 0 dir1/subdir2
2015-03-30 19:00:07 D.... 0 0 dir1/subdir1
2015-03-30 19:00:06 D.... 0 0 dir1
------------------- ----- ------------ ------------ ------------------------
0 0 2 files, 4 folders
rarfiles
$ rar v foo.rar
RAR 4.20 Copyright (c) 1993-2012 Alexander Roshal 9 Jun 2012
Trial version Type RAR -? for help
Archive foo.rar
Pathname/Comment
Size Packed Ratio Date Time Attr CRC Meth Ver
-------------------------------------------------------------------------------
dir1/subdir1/file
0 8 0% 30-03-15 19:00 -rw-r--r-- 00000000 m3b 2.9
dir1/subdir2/file
0 8 0% 30-03-15 19:00 -rw-r--r-- 00000000 m3b 2.9
dir1/subdir1
0 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0
dir1/subdir2
0 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0
dir1
0 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0
dir2
0 0 0% 30-03-15 19:07 drwxr-xr-x 00000000 m0 2.0
-------------------------------------------------------------------------------
6 0 16 0%
That's most of the more popular archive formats. With all this in mind, you could write a little script that uses the appropriate command depending on the extension of the file you give to it:
#!/usr/bin/env bash
for file in "$@"
do
printf "n-----nArchive '%s'n-----n" "$file"
## Get the file's extension
ext=${file##*.}
## Special case for compressed tar files. They sometimes
## have extensions like tar.bz2 or tar.gz etc.
[[ "$(basename "$file" ."$ext")" =~ .tar$ ]] && ext="tgz"
case $ext in
7z)
type 7z >/dev/null 2>&1 && 7z l "$file" ||
echo "ERROR: no 7z program installed"
;;
tar|tbz|tgz)
type tar >/dev/null 2>&1 && tar tf "$file"||
echo "ERROR: no tar program installed"
;;
rar)
type rar >/dev/null 2>&1 && rar v "$file"||
echo "ERROR: no rar program installed"
;;
zip)
type zip >/dev/null 2>&1 && zip -sf "$file"||
echo "ERROR: no zip program installed"
;;
*)
echo "Unknown extension: '$ext', skipping..."
;;
esac
done
Save that script in your PATH and make it executable. You can then list the contents of any archive:
$ list_archive.sh foo.rar foo.tar.bz foo.tar.gz foo.tbz foo.zip
-----
Archive 'foo.rar'
-----
RAR 4.20 Copyright (c) 1993-2012 Alexander Roshal 9 Jun 2012
Trial version Type RAR -? for help
Archive foo.rar
Pathname/Comment
Size Packed Ratio Date Time Attr CRC Meth Ver
-------------------------------------------------------------------------------
dir1/subdir1/file
0 8 0% 30-03-15 19:00 -rw-r--r-- 00000000 m3b 2.9
dir1/file
0 8 0% 30-03-15 19:29 -rw-r--r-- 00000000 m3b 2.9
dir1/subdir1
0 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0
dir1
0 0 0% 30-03-15 19:29 drwxr-xr-x 00000000 m0 2.0
dir2
0 0 0% 30-03-15 19:07 drwxr-xr-x 00000000 m0 2.0
-------------------------------------------------------------------------------
5 0 16 0%
-----
Archive 'foo.tar.bz'
-----
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/file
dir2/
-----
Archive 'foo.tar.gz'
-----
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/file
dir2/
-----
Archive 'foo.tbz'
-----
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/file
dir2/
-----
Archive 'foo.zip'
-----
Archive contains:
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/file
dir2/
Total 5 entries (0 bytes)
And since someone mentioned that lesser editor, naturally, emacs can also do this:

add a comment |
up vote
8
down vote
tar's -t flag will list contents for you. Add that to your other flags (so -tvfz for a tar.gz, -tvfj for a tar.bz2, etc) and you can browse without extracting. From there you can extract single files quite easily
tar -xvfz mybackup.tar.gz path/to/file
The big problem with tar is remembering all the other flags. So I usually rely on 7z (of the p7zip-full package) to do all my archiving. I won't claim it is entirely better but it supports almost everything (without having to specify compression type) and the arguments are logical.
7z l archive.ext
7z e archive.ext path/to/file
It's certainly less capable, but you don't need the man page to use it.
There's also Midnight Commander (mc). This is an all-around badass for quasi-graphical terminal-based file management and with some light testing it just let you browse into both .tar.gz and .7z archives. I'm not sure how many others it supports.
t-ar used to be and the name indeed stands for tape archiver, that screams sequential and is in many cases a PIA. Especially as the inevitable double tar + gz this is just cruel. Also moving to 7zip now.
– Frank Nocke
Feb 25 '17 at 12:21
add a comment |
up vote
6
down vote
Why not use vim to browse your archive and open files (at least text-like files):
vim archive.tar.gz

Press the arrow keys to scroll and Enter to open a file.
add a comment |
up vote
4
down vote
Midnight Commander (mc) also has a good compressed file viewer, although I consider this a bit of cheating since mc is a file manager, albeit a text-based one.
Also, if all you want is to see what's inside compressed archives, you could learn the "view" command for each compressor. tar tzvf will show you the contents of a tar file, unzip -l will do it for a zip file, and so on.
add a comment |
up vote
2
down vote
Using
view filename.tar.gz
will also work. much in the same way vim does, but without write permissions.
add a comment |
up vote
2
down vote
lesspipe is a shell script installed by default as part of the less package that can list the contents of a tar.gz archive, as well as a range of other common archive file formats.
$ lesspipe example.tar.gz
drwxrwxr-x ubuntu/ubuntu 0 2018-11-16 05:32 example/
-rw-rw-r-- ubuntu/ubuntu 7 2018-11-16 05:32 example/ask.txt
-rw-rw-r-- ubuntu/ubuntu 7 2018-11-16 05:32 example/ubuntu.txt
It is called by the less command (see Oli's answer) as an input preprocessor if the $LESSOPEN environment variable is set appropriately.
If feeling adventurous, take a peak at vi /usr/bin/lesspipe to see what commands it uses. For files matching the tar.gz extension, we can see that it uses tar tzvf under the hood along with the --force-local option to disable an obscure feature of tar that would otherwise confuse colons in the filename with a command to use a remote tape drive:
*.tar.gz|*.tgz|*.tar.z|*.tar.dz)
tar tzvf "$1" --force-local
Note that because it's primarily designed as a preprocessor for less, it won't output anything if it doesn't recognise the file type. I noticed that some .tar.gz files I downloaded wouldn't work because they didn't actually use gzip compression despite the filename.
New contributor
anjsimmo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
10 Answers
10
active
oldest
votes
10 Answers
10
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
222
down vote
accepted
Run the below command in the terminal to see the contents of a tar.gz file without extracting it:
tar -tf filename.tar.gz

1
does all these examples to look inside compressed file works on other types of format too. like zip , rar , tar etc. ?
– Ciasto piekarz
Aug 4 '15 at 11:23
1
tar -tvf xxx.tgzthis would also show detail properties of files.
– Eric Wang
Mar 21 '17 at 2:10
3
pipe it totreeto see a tree viewtar -tf filename.tar.gz | tree
– blockloop
Apr 6 '17 at 15:28
For zip / rar useunzip -l/unrar -l
– RoVo
Jun 9 '17 at 13:55
add a comment |
up vote
222
down vote
accepted
Run the below command in the terminal to see the contents of a tar.gz file without extracting it:
tar -tf filename.tar.gz

1
does all these examples to look inside compressed file works on other types of format too. like zip , rar , tar etc. ?
– Ciasto piekarz
Aug 4 '15 at 11:23
1
tar -tvf xxx.tgzthis would also show detail properties of files.
– Eric Wang
Mar 21 '17 at 2:10
3
pipe it totreeto see a tree viewtar -tf filename.tar.gz | tree
– blockloop
Apr 6 '17 at 15:28
For zip / rar useunzip -l/unrar -l
– RoVo
Jun 9 '17 at 13:55
add a comment |
up vote
222
down vote
accepted
up vote
222
down vote
accepted
Run the below command in the terminal to see the contents of a tar.gz file without extracting it:
tar -tf filename.tar.gz

Run the below command in the terminal to see the contents of a tar.gz file without extracting it:
tar -tf filename.tar.gz

edited Jul 18 at 7:15
Melebius
4,16051836
4,16051836
answered Dec 19 '13 at 5:47
Avinash Raj
50.9k41165210
50.9k41165210
1
does all these examples to look inside compressed file works on other types of format too. like zip , rar , tar etc. ?
– Ciasto piekarz
Aug 4 '15 at 11:23
1
tar -tvf xxx.tgzthis would also show detail properties of files.
– Eric Wang
Mar 21 '17 at 2:10
3
pipe it totreeto see a tree viewtar -tf filename.tar.gz | tree
– blockloop
Apr 6 '17 at 15:28
For zip / rar useunzip -l/unrar -l
– RoVo
Jun 9 '17 at 13:55
add a comment |
1
does all these examples to look inside compressed file works on other types of format too. like zip , rar , tar etc. ?
– Ciasto piekarz
Aug 4 '15 at 11:23
1
tar -tvf xxx.tgzthis would also show detail properties of files.
– Eric Wang
Mar 21 '17 at 2:10
3
pipe it totreeto see a tree viewtar -tf filename.tar.gz | tree
– blockloop
Apr 6 '17 at 15:28
For zip / rar useunzip -l/unrar -l
– RoVo
Jun 9 '17 at 13:55
1
1
does all these examples to look inside compressed file works on other types of format too. like zip , rar , tar etc. ?
– Ciasto piekarz
Aug 4 '15 at 11:23
does all these examples to look inside compressed file works on other types of format too. like zip , rar , tar etc. ?
– Ciasto piekarz
Aug 4 '15 at 11:23
1
1
tar -tvf xxx.tgz this would also show detail properties of files.– Eric Wang
Mar 21 '17 at 2:10
tar -tvf xxx.tgz this would also show detail properties of files.– Eric Wang
Mar 21 '17 at 2:10
3
3
pipe it to
tree to see a tree view tar -tf filename.tar.gz | tree – blockloop
Apr 6 '17 at 15:28
pipe it to
tree to see a tree view tar -tf filename.tar.gz | tree – blockloop
Apr 6 '17 at 15:28
For zip / rar use
unzip -l / unrar -l– RoVo
Jun 9 '17 at 13:55
For zip / rar use
unzip -l / unrar -l– RoVo
Jun 9 '17 at 13:55
add a comment |
up vote
99
down vote
You can also use vim
vim filename.tar.gz
7
This is awesome. You can also see the contents of the files!
– Nico
Oct 21 '14 at 13:24
1
Or use Ex editor:ex +%p foo.tar.gz.
– kenorb
Jul 23 '15 at 14:33
@Nico How do you use this to see the contents of a file within the tgz?
– 1252748
Dec 14 '16 at 19:15
1
When you open de file with vim (vim file.tar.gz) it says "Select a file with cursor and press ENTER". You do just that, move the cursor over a file and press ENTER.
– Nico
Dec 15 '16 at 19:56
2
With huge archive you just have to be patient. It can be very long to load folder structure. :-)
– Hugo H
Jul 27 '17 at 17:03
|
show 3 more comments
up vote
99
down vote
You can also use vim
vim filename.tar.gz
7
This is awesome. You can also see the contents of the files!
– Nico
Oct 21 '14 at 13:24
1
Or use Ex editor:ex +%p foo.tar.gz.
– kenorb
Jul 23 '15 at 14:33
@Nico How do you use this to see the contents of a file within the tgz?
– 1252748
Dec 14 '16 at 19:15
1
When you open de file with vim (vim file.tar.gz) it says "Select a file with cursor and press ENTER". You do just that, move the cursor over a file and press ENTER.
– Nico
Dec 15 '16 at 19:56
2
With huge archive you just have to be patient. It can be very long to load folder structure. :-)
– Hugo H
Jul 27 '17 at 17:03
|
show 3 more comments
up vote
99
down vote
up vote
99
down vote
You can also use vim
vim filename.tar.gz
You can also use vim
vim filename.tar.gz
answered Dec 19 '13 at 5:49
s.m
1,3141913
1,3141913
7
This is awesome. You can also see the contents of the files!
– Nico
Oct 21 '14 at 13:24
1
Or use Ex editor:ex +%p foo.tar.gz.
– kenorb
Jul 23 '15 at 14:33
@Nico How do you use this to see the contents of a file within the tgz?
– 1252748
Dec 14 '16 at 19:15
1
When you open de file with vim (vim file.tar.gz) it says "Select a file with cursor and press ENTER". You do just that, move the cursor over a file and press ENTER.
– Nico
Dec 15 '16 at 19:56
2
With huge archive you just have to be patient. It can be very long to load folder structure. :-)
– Hugo H
Jul 27 '17 at 17:03
|
show 3 more comments
7
This is awesome. You can also see the contents of the files!
– Nico
Oct 21 '14 at 13:24
1
Or use Ex editor:ex +%p foo.tar.gz.
– kenorb
Jul 23 '15 at 14:33
@Nico How do you use this to see the contents of a file within the tgz?
– 1252748
Dec 14 '16 at 19:15
1
When you open de file with vim (vim file.tar.gz) it says "Select a file with cursor and press ENTER". You do just that, move the cursor over a file and press ENTER.
– Nico
Dec 15 '16 at 19:56
2
With huge archive you just have to be patient. It can be very long to load folder structure. :-)
– Hugo H
Jul 27 '17 at 17:03
7
7
This is awesome. You can also see the contents of the files!
– Nico
Oct 21 '14 at 13:24
This is awesome. You can also see the contents of the files!
– Nico
Oct 21 '14 at 13:24
1
1
Or use Ex editor:
ex +%p foo.tar.gz.– kenorb
Jul 23 '15 at 14:33
Or use Ex editor:
ex +%p foo.tar.gz.– kenorb
Jul 23 '15 at 14:33
@Nico How do you use this to see the contents of a file within the tgz?
– 1252748
Dec 14 '16 at 19:15
@Nico How do you use this to see the contents of a file within the tgz?
– 1252748
Dec 14 '16 at 19:15
1
1
When you open de file with vim (
vim file.tar.gz) it says "Select a file with cursor and press ENTER". You do just that, move the cursor over a file and press ENTER.– Nico
Dec 15 '16 at 19:56
When you open de file with vim (
vim file.tar.gz) it says "Select a file with cursor and press ENTER". You do just that, move the cursor over a file and press ENTER.– Nico
Dec 15 '16 at 19:56
2
2
With huge archive you just have to be patient. It can be very long to load folder structure. :-)
– Hugo H
Jul 27 '17 at 17:03
With huge archive you just have to be patient. It can be very long to load folder structure. :-)
– Hugo H
Jul 27 '17 at 17:03
|
show 3 more comments
up vote
36
down vote
less can also open gz-compressed and uncompressed tar archives. It gives you a lovely ls -l style output too:
$ less ~/src/compiz_0.9.7.8-0ubuntu1.6.debian.tar.gz
drwxrwxr-x 0/0 0 2012-09-21 11:41 debian/
drwxrwxr-x 0/0 0 2012-08-09 13:32 debian/source/
-rw-rw-r-- 0/0 12 2012-08-09 13:32 debian/source/format
-rw-rw-r-- 0/0 25 2012-08-09 13:32 debian/libdecoration0-dev.docs
-rw-rw-r-- 0/0 25 2012-08-09 13:32 debian/compiz-dev.docs
-rw-rw-r-- 0/0 347 2012-08-09 13:32 debian/compiz-core.install
-rw-rw-r-- 0/0 125 2012-08-09 13:32 debian/libdecoration0-dev.install
...
And because it's less, you can scroll through it, search it, etc. However it fails miserably with other compression algorithms (in my experience).
3
Didn't work for me. Displayed as a binary file.
– JeromeJ
Dec 10 '17 at 16:31
1
You sure you don't have analiaswith special options forlessthat you're not showing here? I just tried that to see, but it didn't work. I don't have any aliases setup forless.
– code_dredd
Jul 20 at 22:14
add a comment |
up vote
36
down vote
less can also open gz-compressed and uncompressed tar archives. It gives you a lovely ls -l style output too:
$ less ~/src/compiz_0.9.7.8-0ubuntu1.6.debian.tar.gz
drwxrwxr-x 0/0 0 2012-09-21 11:41 debian/
drwxrwxr-x 0/0 0 2012-08-09 13:32 debian/source/
-rw-rw-r-- 0/0 12 2012-08-09 13:32 debian/source/format
-rw-rw-r-- 0/0 25 2012-08-09 13:32 debian/libdecoration0-dev.docs
-rw-rw-r-- 0/0 25 2012-08-09 13:32 debian/compiz-dev.docs
-rw-rw-r-- 0/0 347 2012-08-09 13:32 debian/compiz-core.install
-rw-rw-r-- 0/0 125 2012-08-09 13:32 debian/libdecoration0-dev.install
...
And because it's less, you can scroll through it, search it, etc. However it fails miserably with other compression algorithms (in my experience).
3
Didn't work for me. Displayed as a binary file.
– JeromeJ
Dec 10 '17 at 16:31
1
You sure you don't have analiaswith special options forlessthat you're not showing here? I just tried that to see, but it didn't work. I don't have any aliases setup forless.
– code_dredd
Jul 20 at 22:14
add a comment |
up vote
36
down vote
up vote
36
down vote
less can also open gz-compressed and uncompressed tar archives. It gives you a lovely ls -l style output too:
$ less ~/src/compiz_0.9.7.8-0ubuntu1.6.debian.tar.gz
drwxrwxr-x 0/0 0 2012-09-21 11:41 debian/
drwxrwxr-x 0/0 0 2012-08-09 13:32 debian/source/
-rw-rw-r-- 0/0 12 2012-08-09 13:32 debian/source/format
-rw-rw-r-- 0/0 25 2012-08-09 13:32 debian/libdecoration0-dev.docs
-rw-rw-r-- 0/0 25 2012-08-09 13:32 debian/compiz-dev.docs
-rw-rw-r-- 0/0 347 2012-08-09 13:32 debian/compiz-core.install
-rw-rw-r-- 0/0 125 2012-08-09 13:32 debian/libdecoration0-dev.install
...
And because it's less, you can scroll through it, search it, etc. However it fails miserably with other compression algorithms (in my experience).
less can also open gz-compressed and uncompressed tar archives. It gives you a lovely ls -l style output too:
$ less ~/src/compiz_0.9.7.8-0ubuntu1.6.debian.tar.gz
drwxrwxr-x 0/0 0 2012-09-21 11:41 debian/
drwxrwxr-x 0/0 0 2012-08-09 13:32 debian/source/
-rw-rw-r-- 0/0 12 2012-08-09 13:32 debian/source/format
-rw-rw-r-- 0/0 25 2012-08-09 13:32 debian/libdecoration0-dev.docs
-rw-rw-r-- 0/0 25 2012-08-09 13:32 debian/compiz-dev.docs
-rw-rw-r-- 0/0 347 2012-08-09 13:32 debian/compiz-core.install
-rw-rw-r-- 0/0 125 2012-08-09 13:32 debian/libdecoration0-dev.install
...
And because it's less, you can scroll through it, search it, etc. However it fails miserably with other compression algorithms (in my experience).
answered Dec 19 '13 at 14:00
Oli♦
218k85547758
218k85547758
3
Didn't work for me. Displayed as a binary file.
– JeromeJ
Dec 10 '17 at 16:31
1
You sure you don't have analiaswith special options forlessthat you're not showing here? I just tried that to see, but it didn't work. I don't have any aliases setup forless.
– code_dredd
Jul 20 at 22:14
add a comment |
3
Didn't work for me. Displayed as a binary file.
– JeromeJ
Dec 10 '17 at 16:31
1
You sure you don't have analiaswith special options forlessthat you're not showing here? I just tried that to see, but it didn't work. I don't have any aliases setup forless.
– code_dredd
Jul 20 at 22:14
3
3
Didn't work for me. Displayed as a binary file.
– JeromeJ
Dec 10 '17 at 16:31
Didn't work for me. Displayed as a binary file.
– JeromeJ
Dec 10 '17 at 16:31
1
1
You sure you don't have an
alias with special options for less that you're not showing here? I just tried that to see, but it didn't work. I don't have any aliases setup for less.– code_dredd
Jul 20 at 22:14
You sure you don't have an
alias with special options for less that you're not showing here? I just tried that to see, but it didn't work. I don't have any aliases setup for less.– code_dredd
Jul 20 at 22:14
add a comment |
up vote
32
down vote
You could use the z command: zcat, zless, zgrep.
To view a files content use:
zcat file.gz
To grep something use:
zgrep test file.gz
To check difference between files use:
zdiff file1.gz file2.gz
These are just a few example, there are many more.
add a comment |
up vote
32
down vote
You could use the z command: zcat, zless, zgrep.
To view a files content use:
zcat file.gz
To grep something use:
zgrep test file.gz
To check difference between files use:
zdiff file1.gz file2.gz
These are just a few example, there are many more.
add a comment |
up vote
32
down vote
up vote
32
down vote
You could use the z command: zcat, zless, zgrep.
To view a files content use:
zcat file.gz
To grep something use:
zgrep test file.gz
To check difference between files use:
zdiff file1.gz file2.gz
These are just a few example, there are many more.
You could use the z command: zcat, zless, zgrep.
To view a files content use:
zcat file.gz
To grep something use:
zgrep test file.gz
To check difference between files use:
zdiff file1.gz file2.gz
These are just a few example, there are many more.
edited Mar 30 '15 at 16:13
Seth♦
33.3k25109159
33.3k25109159
answered Mar 30 '15 at 15:53
krt
1,182712
1,182712
add a comment |
add a comment |
up vote
9
down vote
Well, that depends on the file. Most (de)compression programs have a flag that lists an archive's contents.
tar/tar.gz/tgz/tar.xz/tar.bz2/tbzfiles
$ tar tf foo.tgz
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/subdir2/
dir1/subdir2/file
dir2/
zipfiles
$ zip -sf foo.zip
Archive contains:
dir1/
dir2/
dir1/subdir1/
dir1/subdir1/file
dir1/subdir2/
dir1/subdir2/file
Total 6 entries (0 bytes)
7zipfiles
$ 7z l foo.7z
7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
p7zip Version 9.20 (locale=en_US.utf8,Utf16=on,HugeFiles=on,4 CPUs)
Listing archive: foo.7z
--
Path = foo.7z
Type = 7z
Solid = -
Blocks = 0
Physical Size = 168
Headers Size = 168
Date Time Attr Size Compressed Name
------------------- ----- ------------ ------------ ------------------------
2015-03-30 19:00:07 ....A 0 0 dir1/subdir1/file
2015-03-30 19:00:07 ....A 0 0 dir1/subdir2/file
2015-03-30 19:07:32 D.... 0 0 dir2
2015-03-30 19:00:07 D.... 0 0 dir1/subdir2
2015-03-30 19:00:07 D.... 0 0 dir1/subdir1
2015-03-30 19:00:06 D.... 0 0 dir1
------------------- ----- ------------ ------------ ------------------------
0 0 2 files, 4 folders
rarfiles
$ rar v foo.rar
RAR 4.20 Copyright (c) 1993-2012 Alexander Roshal 9 Jun 2012
Trial version Type RAR -? for help
Archive foo.rar
Pathname/Comment
Size Packed Ratio Date Time Attr CRC Meth Ver
-------------------------------------------------------------------------------
dir1/subdir1/file
0 8 0% 30-03-15 19:00 -rw-r--r-- 00000000 m3b 2.9
dir1/subdir2/file
0 8 0% 30-03-15 19:00 -rw-r--r-- 00000000 m3b 2.9
dir1/subdir1
0 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0
dir1/subdir2
0 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0
dir1
0 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0
dir2
0 0 0% 30-03-15 19:07 drwxr-xr-x 00000000 m0 2.0
-------------------------------------------------------------------------------
6 0 16 0%
That's most of the more popular archive formats. With all this in mind, you could write a little script that uses the appropriate command depending on the extension of the file you give to it:
#!/usr/bin/env bash
for file in "$@"
do
printf "n-----nArchive '%s'n-----n" "$file"
## Get the file's extension
ext=${file##*.}
## Special case for compressed tar files. They sometimes
## have extensions like tar.bz2 or tar.gz etc.
[[ "$(basename "$file" ."$ext")" =~ .tar$ ]] && ext="tgz"
case $ext in
7z)
type 7z >/dev/null 2>&1 && 7z l "$file" ||
echo "ERROR: no 7z program installed"
;;
tar|tbz|tgz)
type tar >/dev/null 2>&1 && tar tf "$file"||
echo "ERROR: no tar program installed"
;;
rar)
type rar >/dev/null 2>&1 && rar v "$file"||
echo "ERROR: no rar program installed"
;;
zip)
type zip >/dev/null 2>&1 && zip -sf "$file"||
echo "ERROR: no zip program installed"
;;
*)
echo "Unknown extension: '$ext', skipping..."
;;
esac
done
Save that script in your PATH and make it executable. You can then list the contents of any archive:
$ list_archive.sh foo.rar foo.tar.bz foo.tar.gz foo.tbz foo.zip
-----
Archive 'foo.rar'
-----
RAR 4.20 Copyright (c) 1993-2012 Alexander Roshal 9 Jun 2012
Trial version Type RAR -? for help
Archive foo.rar
Pathname/Comment
Size Packed Ratio Date Time Attr CRC Meth Ver
-------------------------------------------------------------------------------
dir1/subdir1/file
0 8 0% 30-03-15 19:00 -rw-r--r-- 00000000 m3b 2.9
dir1/file
0 8 0% 30-03-15 19:29 -rw-r--r-- 00000000 m3b 2.9
dir1/subdir1
0 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0
dir1
0 0 0% 30-03-15 19:29 drwxr-xr-x 00000000 m0 2.0
dir2
0 0 0% 30-03-15 19:07 drwxr-xr-x 00000000 m0 2.0
-------------------------------------------------------------------------------
5 0 16 0%
-----
Archive 'foo.tar.bz'
-----
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/file
dir2/
-----
Archive 'foo.tar.gz'
-----
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/file
dir2/
-----
Archive 'foo.tbz'
-----
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/file
dir2/
-----
Archive 'foo.zip'
-----
Archive contains:
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/file
dir2/
Total 5 entries (0 bytes)
And since someone mentioned that lesser editor, naturally, emacs can also do this:

add a comment |
up vote
9
down vote
Well, that depends on the file. Most (de)compression programs have a flag that lists an archive's contents.
tar/tar.gz/tgz/tar.xz/tar.bz2/tbzfiles
$ tar tf foo.tgz
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/subdir2/
dir1/subdir2/file
dir2/
zipfiles
$ zip -sf foo.zip
Archive contains:
dir1/
dir2/
dir1/subdir1/
dir1/subdir1/file
dir1/subdir2/
dir1/subdir2/file
Total 6 entries (0 bytes)
7zipfiles
$ 7z l foo.7z
7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
p7zip Version 9.20 (locale=en_US.utf8,Utf16=on,HugeFiles=on,4 CPUs)
Listing archive: foo.7z
--
Path = foo.7z
Type = 7z
Solid = -
Blocks = 0
Physical Size = 168
Headers Size = 168
Date Time Attr Size Compressed Name
------------------- ----- ------------ ------------ ------------------------
2015-03-30 19:00:07 ....A 0 0 dir1/subdir1/file
2015-03-30 19:00:07 ....A 0 0 dir1/subdir2/file
2015-03-30 19:07:32 D.... 0 0 dir2
2015-03-30 19:00:07 D.... 0 0 dir1/subdir2
2015-03-30 19:00:07 D.... 0 0 dir1/subdir1
2015-03-30 19:00:06 D.... 0 0 dir1
------------------- ----- ------------ ------------ ------------------------
0 0 2 files, 4 folders
rarfiles
$ rar v foo.rar
RAR 4.20 Copyright (c) 1993-2012 Alexander Roshal 9 Jun 2012
Trial version Type RAR -? for help
Archive foo.rar
Pathname/Comment
Size Packed Ratio Date Time Attr CRC Meth Ver
-------------------------------------------------------------------------------
dir1/subdir1/file
0 8 0% 30-03-15 19:00 -rw-r--r-- 00000000 m3b 2.9
dir1/subdir2/file
0 8 0% 30-03-15 19:00 -rw-r--r-- 00000000 m3b 2.9
dir1/subdir1
0 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0
dir1/subdir2
0 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0
dir1
0 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0
dir2
0 0 0% 30-03-15 19:07 drwxr-xr-x 00000000 m0 2.0
-------------------------------------------------------------------------------
6 0 16 0%
That's most of the more popular archive formats. With all this in mind, you could write a little script that uses the appropriate command depending on the extension of the file you give to it:
#!/usr/bin/env bash
for file in "$@"
do
printf "n-----nArchive '%s'n-----n" "$file"
## Get the file's extension
ext=${file##*.}
## Special case for compressed tar files. They sometimes
## have extensions like tar.bz2 or tar.gz etc.
[[ "$(basename "$file" ."$ext")" =~ .tar$ ]] && ext="tgz"
case $ext in
7z)
type 7z >/dev/null 2>&1 && 7z l "$file" ||
echo "ERROR: no 7z program installed"
;;
tar|tbz|tgz)
type tar >/dev/null 2>&1 && tar tf "$file"||
echo "ERROR: no tar program installed"
;;
rar)
type rar >/dev/null 2>&1 && rar v "$file"||
echo "ERROR: no rar program installed"
;;
zip)
type zip >/dev/null 2>&1 && zip -sf "$file"||
echo "ERROR: no zip program installed"
;;
*)
echo "Unknown extension: '$ext', skipping..."
;;
esac
done
Save that script in your PATH and make it executable. You can then list the contents of any archive:
$ list_archive.sh foo.rar foo.tar.bz foo.tar.gz foo.tbz foo.zip
-----
Archive 'foo.rar'
-----
RAR 4.20 Copyright (c) 1993-2012 Alexander Roshal 9 Jun 2012
Trial version Type RAR -? for help
Archive foo.rar
Pathname/Comment
Size Packed Ratio Date Time Attr CRC Meth Ver
-------------------------------------------------------------------------------
dir1/subdir1/file
0 8 0% 30-03-15 19:00 -rw-r--r-- 00000000 m3b 2.9
dir1/file
0 8 0% 30-03-15 19:29 -rw-r--r-- 00000000 m3b 2.9
dir1/subdir1
0 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0
dir1
0 0 0% 30-03-15 19:29 drwxr-xr-x 00000000 m0 2.0
dir2
0 0 0% 30-03-15 19:07 drwxr-xr-x 00000000 m0 2.0
-------------------------------------------------------------------------------
5 0 16 0%
-----
Archive 'foo.tar.bz'
-----
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/file
dir2/
-----
Archive 'foo.tar.gz'
-----
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/file
dir2/
-----
Archive 'foo.tbz'
-----
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/file
dir2/
-----
Archive 'foo.zip'
-----
Archive contains:
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/file
dir2/
Total 5 entries (0 bytes)
And since someone mentioned that lesser editor, naturally, emacs can also do this:

add a comment |
up vote
9
down vote
up vote
9
down vote
Well, that depends on the file. Most (de)compression programs have a flag that lists an archive's contents.
tar/tar.gz/tgz/tar.xz/tar.bz2/tbzfiles
$ tar tf foo.tgz
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/subdir2/
dir1/subdir2/file
dir2/
zipfiles
$ zip -sf foo.zip
Archive contains:
dir1/
dir2/
dir1/subdir1/
dir1/subdir1/file
dir1/subdir2/
dir1/subdir2/file
Total 6 entries (0 bytes)
7zipfiles
$ 7z l foo.7z
7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
p7zip Version 9.20 (locale=en_US.utf8,Utf16=on,HugeFiles=on,4 CPUs)
Listing archive: foo.7z
--
Path = foo.7z
Type = 7z
Solid = -
Blocks = 0
Physical Size = 168
Headers Size = 168
Date Time Attr Size Compressed Name
------------------- ----- ------------ ------------ ------------------------
2015-03-30 19:00:07 ....A 0 0 dir1/subdir1/file
2015-03-30 19:00:07 ....A 0 0 dir1/subdir2/file
2015-03-30 19:07:32 D.... 0 0 dir2
2015-03-30 19:00:07 D.... 0 0 dir1/subdir2
2015-03-30 19:00:07 D.... 0 0 dir1/subdir1
2015-03-30 19:00:06 D.... 0 0 dir1
------------------- ----- ------------ ------------ ------------------------
0 0 2 files, 4 folders
rarfiles
$ rar v foo.rar
RAR 4.20 Copyright (c) 1993-2012 Alexander Roshal 9 Jun 2012
Trial version Type RAR -? for help
Archive foo.rar
Pathname/Comment
Size Packed Ratio Date Time Attr CRC Meth Ver
-------------------------------------------------------------------------------
dir1/subdir1/file
0 8 0% 30-03-15 19:00 -rw-r--r-- 00000000 m3b 2.9
dir1/subdir2/file
0 8 0% 30-03-15 19:00 -rw-r--r-- 00000000 m3b 2.9
dir1/subdir1
0 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0
dir1/subdir2
0 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0
dir1
0 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0
dir2
0 0 0% 30-03-15 19:07 drwxr-xr-x 00000000 m0 2.0
-------------------------------------------------------------------------------
6 0 16 0%
That's most of the more popular archive formats. With all this in mind, you could write a little script that uses the appropriate command depending on the extension of the file you give to it:
#!/usr/bin/env bash
for file in "$@"
do
printf "n-----nArchive '%s'n-----n" "$file"
## Get the file's extension
ext=${file##*.}
## Special case for compressed tar files. They sometimes
## have extensions like tar.bz2 or tar.gz etc.
[[ "$(basename "$file" ."$ext")" =~ .tar$ ]] && ext="tgz"
case $ext in
7z)
type 7z >/dev/null 2>&1 && 7z l "$file" ||
echo "ERROR: no 7z program installed"
;;
tar|tbz|tgz)
type tar >/dev/null 2>&1 && tar tf "$file"||
echo "ERROR: no tar program installed"
;;
rar)
type rar >/dev/null 2>&1 && rar v "$file"||
echo "ERROR: no rar program installed"
;;
zip)
type zip >/dev/null 2>&1 && zip -sf "$file"||
echo "ERROR: no zip program installed"
;;
*)
echo "Unknown extension: '$ext', skipping..."
;;
esac
done
Save that script in your PATH and make it executable. You can then list the contents of any archive:
$ list_archive.sh foo.rar foo.tar.bz foo.tar.gz foo.tbz foo.zip
-----
Archive 'foo.rar'
-----
RAR 4.20 Copyright (c) 1993-2012 Alexander Roshal 9 Jun 2012
Trial version Type RAR -? for help
Archive foo.rar
Pathname/Comment
Size Packed Ratio Date Time Attr CRC Meth Ver
-------------------------------------------------------------------------------
dir1/subdir1/file
0 8 0% 30-03-15 19:00 -rw-r--r-- 00000000 m3b 2.9
dir1/file
0 8 0% 30-03-15 19:29 -rw-r--r-- 00000000 m3b 2.9
dir1/subdir1
0 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0
dir1
0 0 0% 30-03-15 19:29 drwxr-xr-x 00000000 m0 2.0
dir2
0 0 0% 30-03-15 19:07 drwxr-xr-x 00000000 m0 2.0
-------------------------------------------------------------------------------
5 0 16 0%
-----
Archive 'foo.tar.bz'
-----
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/file
dir2/
-----
Archive 'foo.tar.gz'
-----
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/file
dir2/
-----
Archive 'foo.tbz'
-----
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/file
dir2/
-----
Archive 'foo.zip'
-----
Archive contains:
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/file
dir2/
Total 5 entries (0 bytes)
And since someone mentioned that lesser editor, naturally, emacs can also do this:

Well, that depends on the file. Most (de)compression programs have a flag that lists an archive's contents.
tar/tar.gz/tgz/tar.xz/tar.bz2/tbzfiles
$ tar tf foo.tgz
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/subdir2/
dir1/subdir2/file
dir2/
zipfiles
$ zip -sf foo.zip
Archive contains:
dir1/
dir2/
dir1/subdir1/
dir1/subdir1/file
dir1/subdir2/
dir1/subdir2/file
Total 6 entries (0 bytes)
7zipfiles
$ 7z l foo.7z
7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
p7zip Version 9.20 (locale=en_US.utf8,Utf16=on,HugeFiles=on,4 CPUs)
Listing archive: foo.7z
--
Path = foo.7z
Type = 7z
Solid = -
Blocks = 0
Physical Size = 168
Headers Size = 168
Date Time Attr Size Compressed Name
------------------- ----- ------------ ------------ ------------------------
2015-03-30 19:00:07 ....A 0 0 dir1/subdir1/file
2015-03-30 19:00:07 ....A 0 0 dir1/subdir2/file
2015-03-30 19:07:32 D.... 0 0 dir2
2015-03-30 19:00:07 D.... 0 0 dir1/subdir2
2015-03-30 19:00:07 D.... 0 0 dir1/subdir1
2015-03-30 19:00:06 D.... 0 0 dir1
------------------- ----- ------------ ------------ ------------------------
0 0 2 files, 4 folders
rarfiles
$ rar v foo.rar
RAR 4.20 Copyright (c) 1993-2012 Alexander Roshal 9 Jun 2012
Trial version Type RAR -? for help
Archive foo.rar
Pathname/Comment
Size Packed Ratio Date Time Attr CRC Meth Ver
-------------------------------------------------------------------------------
dir1/subdir1/file
0 8 0% 30-03-15 19:00 -rw-r--r-- 00000000 m3b 2.9
dir1/subdir2/file
0 8 0% 30-03-15 19:00 -rw-r--r-- 00000000 m3b 2.9
dir1/subdir1
0 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0
dir1/subdir2
0 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0
dir1
0 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0
dir2
0 0 0% 30-03-15 19:07 drwxr-xr-x 00000000 m0 2.0
-------------------------------------------------------------------------------
6 0 16 0%
That's most of the more popular archive formats. With all this in mind, you could write a little script that uses the appropriate command depending on the extension of the file you give to it:
#!/usr/bin/env bash
for file in "$@"
do
printf "n-----nArchive '%s'n-----n" "$file"
## Get the file's extension
ext=${file##*.}
## Special case for compressed tar files. They sometimes
## have extensions like tar.bz2 or tar.gz etc.
[[ "$(basename "$file" ."$ext")" =~ .tar$ ]] && ext="tgz"
case $ext in
7z)
type 7z >/dev/null 2>&1 && 7z l "$file" ||
echo "ERROR: no 7z program installed"
;;
tar|tbz|tgz)
type tar >/dev/null 2>&1 && tar tf "$file"||
echo "ERROR: no tar program installed"
;;
rar)
type rar >/dev/null 2>&1 && rar v "$file"||
echo "ERROR: no rar program installed"
;;
zip)
type zip >/dev/null 2>&1 && zip -sf "$file"||
echo "ERROR: no zip program installed"
;;
*)
echo "Unknown extension: '$ext', skipping..."
;;
esac
done
Save that script in your PATH and make it executable. You can then list the contents of any archive:
$ list_archive.sh foo.rar foo.tar.bz foo.tar.gz foo.tbz foo.zip
-----
Archive 'foo.rar'
-----
RAR 4.20 Copyright (c) 1993-2012 Alexander Roshal 9 Jun 2012
Trial version Type RAR -? for help
Archive foo.rar
Pathname/Comment
Size Packed Ratio Date Time Attr CRC Meth Ver
-------------------------------------------------------------------------------
dir1/subdir1/file
0 8 0% 30-03-15 19:00 -rw-r--r-- 00000000 m3b 2.9
dir1/file
0 8 0% 30-03-15 19:29 -rw-r--r-- 00000000 m3b 2.9
dir1/subdir1
0 0 0% 30-03-15 19:00 drwxr-xr-x 00000000 m0 2.0
dir1
0 0 0% 30-03-15 19:29 drwxr-xr-x 00000000 m0 2.0
dir2
0 0 0% 30-03-15 19:07 drwxr-xr-x 00000000 m0 2.0
-------------------------------------------------------------------------------
5 0 16 0%
-----
Archive 'foo.tar.bz'
-----
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/file
dir2/
-----
Archive 'foo.tar.gz'
-----
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/file
dir2/
-----
Archive 'foo.tbz'
-----
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/file
dir2/
-----
Archive 'foo.zip'
-----
Archive contains:
dir1/
dir1/subdir1/
dir1/subdir1/file
dir1/file
dir2/
Total 5 entries (0 bytes)
And since someone mentioned that lesser editor, naturally, emacs can also do this:

answered Mar 30 '15 at 16:45
terdon♦
63.1k12132209
63.1k12132209
add a comment |
add a comment |
up vote
8
down vote
tar's -t flag will list contents for you. Add that to your other flags (so -tvfz for a tar.gz, -tvfj for a tar.bz2, etc) and you can browse without extracting. From there you can extract single files quite easily
tar -xvfz mybackup.tar.gz path/to/file
The big problem with tar is remembering all the other flags. So I usually rely on 7z (of the p7zip-full package) to do all my archiving. I won't claim it is entirely better but it supports almost everything (without having to specify compression type) and the arguments are logical.
7z l archive.ext
7z e archive.ext path/to/file
It's certainly less capable, but you don't need the man page to use it.
There's also Midnight Commander (mc). This is an all-around badass for quasi-graphical terminal-based file management and with some light testing it just let you browse into both .tar.gz and .7z archives. I'm not sure how many others it supports.
t-ar used to be and the name indeed stands for tape archiver, that screams sequential and is in many cases a PIA. Especially as the inevitable double tar + gz this is just cruel. Also moving to 7zip now.
– Frank Nocke
Feb 25 '17 at 12:21
add a comment |
up vote
8
down vote
tar's -t flag will list contents for you. Add that to your other flags (so -tvfz for a tar.gz, -tvfj for a tar.bz2, etc) and you can browse without extracting. From there you can extract single files quite easily
tar -xvfz mybackup.tar.gz path/to/file
The big problem with tar is remembering all the other flags. So I usually rely on 7z (of the p7zip-full package) to do all my archiving. I won't claim it is entirely better but it supports almost everything (without having to specify compression type) and the arguments are logical.
7z l archive.ext
7z e archive.ext path/to/file
It's certainly less capable, but you don't need the man page to use it.
There's also Midnight Commander (mc). This is an all-around badass for quasi-graphical terminal-based file management and with some light testing it just let you browse into both .tar.gz and .7z archives. I'm not sure how many others it supports.
t-ar used to be and the name indeed stands for tape archiver, that screams sequential and is in many cases a PIA. Especially as the inevitable double tar + gz this is just cruel. Also moving to 7zip now.
– Frank Nocke
Feb 25 '17 at 12:21
add a comment |
up vote
8
down vote
up vote
8
down vote
tar's -t flag will list contents for you. Add that to your other flags (so -tvfz for a tar.gz, -tvfj for a tar.bz2, etc) and you can browse without extracting. From there you can extract single files quite easily
tar -xvfz mybackup.tar.gz path/to/file
The big problem with tar is remembering all the other flags. So I usually rely on 7z (of the p7zip-full package) to do all my archiving. I won't claim it is entirely better but it supports almost everything (without having to specify compression type) and the arguments are logical.
7z l archive.ext
7z e archive.ext path/to/file
It's certainly less capable, but you don't need the man page to use it.
There's also Midnight Commander (mc). This is an all-around badass for quasi-graphical terminal-based file management and with some light testing it just let you browse into both .tar.gz and .7z archives. I'm not sure how many others it supports.
tar's -t flag will list contents for you. Add that to your other flags (so -tvfz for a tar.gz, -tvfj for a tar.bz2, etc) and you can browse without extracting. From there you can extract single files quite easily
tar -xvfz mybackup.tar.gz path/to/file
The big problem with tar is remembering all the other flags. So I usually rely on 7z (of the p7zip-full package) to do all my archiving. I won't claim it is entirely better but it supports almost everything (without having to specify compression type) and the arguments are logical.
7z l archive.ext
7z e archive.ext path/to/file
It's certainly less capable, but you don't need the man page to use it.
There's also Midnight Commander (mc). This is an all-around badass for quasi-graphical terminal-based file management and with some light testing it just let you browse into both .tar.gz and .7z archives. I'm not sure how many others it supports.
edited Mar 30 '15 at 15:57
answered Mar 30 '15 at 15:50
Oli♦
218k85547758
218k85547758
t-ar used to be and the name indeed stands for tape archiver, that screams sequential and is in many cases a PIA. Especially as the inevitable double tar + gz this is just cruel. Also moving to 7zip now.
– Frank Nocke
Feb 25 '17 at 12:21
add a comment |
t-ar used to be and the name indeed stands for tape archiver, that screams sequential and is in many cases a PIA. Especially as the inevitable double tar + gz this is just cruel. Also moving to 7zip now.
– Frank Nocke
Feb 25 '17 at 12:21
t-ar used to be and the name indeed stands for tape archiver, that screams sequential and is in many cases a PIA. Especially as the inevitable double tar + gz this is just cruel. Also moving to 7zip now.
– Frank Nocke
Feb 25 '17 at 12:21
t-ar used to be and the name indeed stands for tape archiver, that screams sequential and is in many cases a PIA. Especially as the inevitable double tar + gz this is just cruel. Also moving to 7zip now.
– Frank Nocke
Feb 25 '17 at 12:21
add a comment |
up vote
6
down vote
Why not use vim to browse your archive and open files (at least text-like files):
vim archive.tar.gz

Press the arrow keys to scroll and Enter to open a file.
add a comment |
up vote
6
down vote
Why not use vim to browse your archive and open files (at least text-like files):
vim archive.tar.gz

Press the arrow keys to scroll and Enter to open a file.
add a comment |
up vote
6
down vote
up vote
6
down vote
Why not use vim to browse your archive and open files (at least text-like files):
vim archive.tar.gz

Press the arrow keys to scroll and Enter to open a file.
Why not use vim to browse your archive and open files (at least text-like files):
vim archive.tar.gz

Press the arrow keys to scroll and Enter to open a file.
edited Mar 30 '15 at 15:49
answered Mar 30 '15 at 15:43
Sylvain Pineau
48.1k16104149
48.1k16104149
add a comment |
add a comment |
up vote
4
down vote
Midnight Commander (mc) also has a good compressed file viewer, although I consider this a bit of cheating since mc is a file manager, albeit a text-based one.
Also, if all you want is to see what's inside compressed archives, you could learn the "view" command for each compressor. tar tzvf will show you the contents of a tar file, unzip -l will do it for a zip file, and so on.
add a comment |
up vote
4
down vote
Midnight Commander (mc) also has a good compressed file viewer, although I consider this a bit of cheating since mc is a file manager, albeit a text-based one.
Also, if all you want is to see what's inside compressed archives, you could learn the "view" command for each compressor. tar tzvf will show you the contents of a tar file, unzip -l will do it for a zip file, and so on.
add a comment |
up vote
4
down vote
up vote
4
down vote
Midnight Commander (mc) also has a good compressed file viewer, although I consider this a bit of cheating since mc is a file manager, albeit a text-based one.
Also, if all you want is to see what's inside compressed archives, you could learn the "view" command for each compressor. tar tzvf will show you the contents of a tar file, unzip -l will do it for a zip file, and so on.
Midnight Commander (mc) also has a good compressed file viewer, although I consider this a bit of cheating since mc is a file manager, albeit a text-based one.
Also, if all you want is to see what's inside compressed archives, you could learn the "view" command for each compressor. tar tzvf will show you the contents of a tar file, unzip -l will do it for a zip file, and so on.
answered Mar 30 '15 at 15:52
roadmr
26.7k56378
26.7k56378
add a comment |
add a comment |
up vote
2
down vote
Using
view filename.tar.gz
will also work. much in the same way vim does, but without write permissions.
add a comment |
up vote
2
down vote
Using
view filename.tar.gz
will also work. much in the same way vim does, but without write permissions.
add a comment |
up vote
2
down vote
up vote
2
down vote
Using
view filename.tar.gz
will also work. much in the same way vim does, but without write permissions.
Using
view filename.tar.gz
will also work. much in the same way vim does, but without write permissions.
answered Jan 22 at 13:44
Jeff
652319
652319
add a comment |
add a comment |
up vote
2
down vote
lesspipe is a shell script installed by default as part of the less package that can list the contents of a tar.gz archive, as well as a range of other common archive file formats.
$ lesspipe example.tar.gz
drwxrwxr-x ubuntu/ubuntu 0 2018-11-16 05:32 example/
-rw-rw-r-- ubuntu/ubuntu 7 2018-11-16 05:32 example/ask.txt
-rw-rw-r-- ubuntu/ubuntu 7 2018-11-16 05:32 example/ubuntu.txt
It is called by the less command (see Oli's answer) as an input preprocessor if the $LESSOPEN environment variable is set appropriately.
If feeling adventurous, take a peak at vi /usr/bin/lesspipe to see what commands it uses. For files matching the tar.gz extension, we can see that it uses tar tzvf under the hood along with the --force-local option to disable an obscure feature of tar that would otherwise confuse colons in the filename with a command to use a remote tape drive:
*.tar.gz|*.tgz|*.tar.z|*.tar.dz)
tar tzvf "$1" --force-local
Note that because it's primarily designed as a preprocessor for less, it won't output anything if it doesn't recognise the file type. I noticed that some .tar.gz files I downloaded wouldn't work because they didn't actually use gzip compression despite the filename.
New contributor
anjsimmo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
2
down vote
lesspipe is a shell script installed by default as part of the less package that can list the contents of a tar.gz archive, as well as a range of other common archive file formats.
$ lesspipe example.tar.gz
drwxrwxr-x ubuntu/ubuntu 0 2018-11-16 05:32 example/
-rw-rw-r-- ubuntu/ubuntu 7 2018-11-16 05:32 example/ask.txt
-rw-rw-r-- ubuntu/ubuntu 7 2018-11-16 05:32 example/ubuntu.txt
It is called by the less command (see Oli's answer) as an input preprocessor if the $LESSOPEN environment variable is set appropriately.
If feeling adventurous, take a peak at vi /usr/bin/lesspipe to see what commands it uses. For files matching the tar.gz extension, we can see that it uses tar tzvf under the hood along with the --force-local option to disable an obscure feature of tar that would otherwise confuse colons in the filename with a command to use a remote tape drive:
*.tar.gz|*.tgz|*.tar.z|*.tar.dz)
tar tzvf "$1" --force-local
Note that because it's primarily designed as a preprocessor for less, it won't output anything if it doesn't recognise the file type. I noticed that some .tar.gz files I downloaded wouldn't work because they didn't actually use gzip compression despite the filename.
New contributor
anjsimmo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
2
down vote
up vote
2
down vote
lesspipe is a shell script installed by default as part of the less package that can list the contents of a tar.gz archive, as well as a range of other common archive file formats.
$ lesspipe example.tar.gz
drwxrwxr-x ubuntu/ubuntu 0 2018-11-16 05:32 example/
-rw-rw-r-- ubuntu/ubuntu 7 2018-11-16 05:32 example/ask.txt
-rw-rw-r-- ubuntu/ubuntu 7 2018-11-16 05:32 example/ubuntu.txt
It is called by the less command (see Oli's answer) as an input preprocessor if the $LESSOPEN environment variable is set appropriately.
If feeling adventurous, take a peak at vi /usr/bin/lesspipe to see what commands it uses. For files matching the tar.gz extension, we can see that it uses tar tzvf under the hood along with the --force-local option to disable an obscure feature of tar that would otherwise confuse colons in the filename with a command to use a remote tape drive:
*.tar.gz|*.tgz|*.tar.z|*.tar.dz)
tar tzvf "$1" --force-local
Note that because it's primarily designed as a preprocessor for less, it won't output anything if it doesn't recognise the file type. I noticed that some .tar.gz files I downloaded wouldn't work because they didn't actually use gzip compression despite the filename.
New contributor
anjsimmo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
lesspipe is a shell script installed by default as part of the less package that can list the contents of a tar.gz archive, as well as a range of other common archive file formats.
$ lesspipe example.tar.gz
drwxrwxr-x ubuntu/ubuntu 0 2018-11-16 05:32 example/
-rw-rw-r-- ubuntu/ubuntu 7 2018-11-16 05:32 example/ask.txt
-rw-rw-r-- ubuntu/ubuntu 7 2018-11-16 05:32 example/ubuntu.txt
It is called by the less command (see Oli's answer) as an input preprocessor if the $LESSOPEN environment variable is set appropriately.
If feeling adventurous, take a peak at vi /usr/bin/lesspipe to see what commands it uses. For files matching the tar.gz extension, we can see that it uses tar tzvf under the hood along with the --force-local option to disable an obscure feature of tar that would otherwise confuse colons in the filename with a command to use a remote tape drive:
*.tar.gz|*.tgz|*.tar.z|*.tar.dz)
tar tzvf "$1" --force-local
Note that because it's primarily designed as a preprocessor for less, it won't output anything if it doesn't recognise the file type. I noticed that some .tar.gz files I downloaded wouldn't work because they didn't actually use gzip compression despite the filename.
New contributor
anjsimmo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 15 mins ago
New contributor
anjsimmo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 1 hour ago
anjsimmo
214
214
New contributor
anjsimmo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
anjsimmo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
anjsimmo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f392885%2fhow-can-i-view-the-contents-of-tar-gz-file-without-extracting-from-the-command-l%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Try
man tar...– Reinier Post
Jun 9 '17 at 13:55