I'm having a large number of tar files and need to browse through them. Is there something like a curses/ncurses tar browser (like midnight commander or ncdu)? I know the -t option for tar but it is not what I need since it lists all files and not in a directory tree.
-
2Midnight Commander does this, though I find its navigation clumsy. You may not. – Thomas Dickey Mar 04 '17 at 14:25
-
Thank you, that's exactly what I needed... how stupid that I didn't try that. – mfnalex Mar 04 '17 at 16:38
-
Don't forget to use the checkmark to indicate an answer that solves your problem – Jeff Schaller Mar 05 '17 at 01:08
-
Thomas Dickey's comment was the solution, but I can't mark it. – mfnalex Mar 06 '17 at 08:02
2 Answers
You can explore your archives from the shell with a filesystem that makes archives appear as directories. AVFS is a virtual filesystem (based on FUSE) that allows you to see inside archives as if they were directories. It's available as a package in many distributions. Run mountavfs once and for all (it'll persist until the next reboot; you should put it in your ~/.profile). This creates a view of the whole filesystem rooted at ~/.avfs. Inside this view, every archive has an associated directory whose name has an extra # at the end. This directory contains the contents of the archive.
mountavfs
cd ~/.avfs$PWD
ls *.tar
cd foo.tar\#
ls
If you prefer to use a full-screen program to browse the directory, then AVFS isn't so convenient because the directory corresponding to the archive does not appear in the directory listing, so you would have to explicitly visit each archive file. But some programs have archive browsing built in. Try Midnight Commander (mc, available as a package in many distributions).
- 807,993
- 194
- 1,674
- 2,175
-
Thank you very much, but I'm using a VPS and my hoster does not support FUSE. – mfnalex Mar 04 '17 at 16:25
-
Sorry, I didn't read you also mentioned midnight commander. That was exactly what I needed, I just didn't know it was able to do that, so thanks! – mfnalex Mar 04 '17 at 16:42
Use t option and pipe into less with optional v option (verbose). eg
tar tvf mytarfile.tar |less
It's easy to search for a pattern in less. Use the / command
If you wish to restrict to a known directory
tar tvf mytarfile.tar path/to/ADirectory | less
- 10,413
- 2
- 33
- 48
-
1Except: "I know the -t option for tar but it is not what I need since it lists all files and not in a directory tree." – Jeff Schaller Mar 04 '17 at 14:54
-
As I said, I know the -t option and need to have an interactive interface in which I can navigate. Thank you anyway. – mfnalex Mar 04 '17 at 16:27