Visit Our UNIX and Linux User Community


No. of files in Tar


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting No. of files in Tar
# 1  
Old 08-24-2009
No. of files in Tar

Hi Frields,
I would like to know the number of files present in a tar without using the command tar -tvf |wc -l

Is their any command for this?
# 2  
Old 08-24-2009
There is no command other than the tar t.
tar is short for tape archive - it was developed for sequential access in a tape drive. So there is no metadata like you have for a direct access filesystem.
# 3  
Old 08-24-2009
Hi,

Please can you explain why you do not want to use this command.

Cheers,
Shazin
# 4  
Old 08-24-2009
Hi,

Please can you explain why you do not want to use this command.

Cheers,
Shazin
# 5  
Old 08-24-2009
Hi ,

I am looking for an alternative because, their are some thousand files present in the tar and I feel the tar -tvf command is scanning file by file which takes more time.



I am looking for an option, which will give the output much faster.
# 6  
Old 08-24-2009
If you are not in control of creating the "tar" files then the only option is the "t" (or "-t" on some versions) switch as advised by "jim mcnamara".

Have you considered a script to index the "tar" archives and store that index alongside each "tar" file such that you only need to produce the files list once per archive?

In a similar situation I used multiple concurrent jobs in a quiet slot each night to index archive "tar" files in preparation for selective re-archiving without duplicate identical files.
# 7  
Old 08-24-2009
this probably isn't the answer you were looking for, but opening with WinZip or WinRar will give you the number of files present in the archive (but even those provide a table of contents so i'm not sure this would be quicker than 'tar t').

Previous Thread | Next Thread
Test Your Knowledge in Computers #144
Difficulty: Easy
IEEE designed POSIX around the common structure of the major competing variants of the Unix system, publishing the first POSIX standard in 1988.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to create zip/gz/tar files for if the files are older than particular days in UNIX or Linux?

I need a script file for backup (zip or tar or gz) of old log files in our unix server (causing the space problem). Could you please help me to create the zip or gz files for each log files in current directory and sub-directories also? I found one command which is to create gz file for the... (4 Replies)
Discussion started by: Mallikgm
4 Replies

2. Solaris

Command to remove existing files in the tar files in Solaris 10

Hi, I am using solaris 10 OS.Please help me out with the commands needed in below two scenarios. 1)How to delete the existing files in the tar file. suppose i have a main tarfile named application.tar and it contains a file called ingres.tar. what is the command to remove ingres.tar... (2 Replies)
Discussion started by: muraliinfy04
2 Replies

3. UNIX for Dummies Questions & Answers

How to tar all files except logs and .txt files

Hi I greatly appreciate the forum and the people here very helpful :) I could able to tar all the directories, sub dirs and the files. But unable to tar all the directories excluding the log and text files. Can anyone please advise the exact command to use for excluding .log and .txt? PS:... (4 Replies)
Discussion started by: Olivia
4 Replies

4. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

5. Shell Programming and Scripting

How to tar .gz files?

I have the gzip utility installed on machine and now i am compressing the files using gzip command. i need to archive the .gz files using the tar command, but i get the command 'tar' is not recognized as an internal or external command, operable program or batch file. do i need to install the... (3 Replies)
Discussion started by: Codesearcher
3 Replies

6. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

7. UNIX for Advanced & Expert Users

How to create a Tar of multiple Files in Unix and FTP the tar to Windows.

Hi, On my Unix Server in my directory, I have 70 files distributed in the following directories (which have several other files too). These files include C Source Files, Shell Script Source Files, Binary Files, Object Files. a) /usr/users/oracle/bin b) /usr/users/oracle... (1 Reply)
Discussion started by: marconi
1 Replies

8. UNIX for Dummies Questions & Answers

.tar.tar files

I downloaded what I thought was a gziped file (at least on remote server it had a .gz extention) and once I had it it was filename.tar.tar..I tried the standard untar tar -xvf filename on it and get an error. Does anyone know what's going on? (5 Replies)
Discussion started by: capeme
5 Replies

9. Shell Programming and Scripting

How to process the files using .tar.gz files in script

Hi, I have some file in /users/xyz directoty with .tar.gz extension. i need to find these files and if found in need to run other commands. I now the command for finding files,but how to put if condition ?please help me Thanks (3 Replies)
Discussion started by: bmkreddy
3 Replies

10. UNIX for Advanced & Expert Users

Untaring *.tar.tar files

Hi all, How to untar a file with .tar.tar extension. A utility that i downloaded from net had this extension. Thanks in advance, bubeshj. (6 Replies)
Discussion started by: bubeshj
6 Replies

Featured Tech Videos