cli-tarHow can I view the contents of a Unix tar file?
To view the contents of a Unix tar file, you can use the tar command with the tvf option. This command will list the contents of the tar file without extracting it. The general syntax is as follows:
tar tvf <filename>.tar
The output of the command will be a list of the contents of the tar file, including the file name, permissions, owner, size, and timestamp.
The following example code shows the output of the command for a tar file named example.tar:
$ tar tvf example.tar
-rw-r--r-- me/users 0 2019-10-20 15:20 file1.txt
-rw-r--r-- me/users 0 2019-10-20 15:20 file2.txt
-rw-r--r-- me/users 0 2019-10-20 15:20 file3.txt
The parts of the command are as follows:
tar: The tar command is used to create, modify, and extract files from a tar archive.tvf: This option is used to view the contents of a tar file.<filename>.tar: This is the name of the tar file.
Helpful links
More of Cli Tar
- How do I use the Unix tar zip command?
- How do I use the tar command line in Windows 10?
- How do I use the Unix tar xvf command to extract files?
- How do I unzip a tar file using the command line?
- How do I decide which compression format (gzip or tar) to use for my software development project?
- How do I unzip a file using the tar command in a shell?
- How can I fix an unexpected end of file error when compressing a file with tar and gzip?
- How do I read a tar file in Unix?
- How do I use tar and gzip to password protect a file?
See more codes...