How to list all files inside a compressed archive using the command 'lz' (with examples)
- Linux
- December 25, 2023
The ’lz’ command is used to list all files inside a compressed archive, specifically in a ‘.tar.gz’ format. This command is especially useful when you want to inspect the contents of a compressed archive without extracting it.
Use case 1: List all files inside a compressed archive
Code:
lz path/to/file.tar.gz
Explanation:
- ’lz’ : The command itself, used to list files inside a compressed archive.
- ‘path/to/file.tar.gz’ : The path to the compressed archive you want to inspect.
Motivation: This use case is helpful when you want to view the contents of a compressed archive without extracting it. By listing all the files inside the archive, you can quickly check if the desired files are present before extracting or processing the archive further.
Example output:
file1.txt
directory/
directory/file2.txt
In the example above, ’lz’ is used to list the files inside the ‘file.tar.gz’ archive. The output shows that the archive contains ‘file1.txt’ and a directory called ‘directory’, which itself contains ‘file2.txt’.