When doing Linux system operation, sometimes the compressed file is too large, it is inconvenient to decompress, if only one of the files is needed, Also want to know how big the file is, what should I do? The following small series will introduce you to how to view the size of the files under Linux without unpacking the tar.gz file. Let's learn together.
see how not unpack the files tar.gz file size
tar tvf my_file.tar.gz
output of the form:
-rwxr-xr-x root/root 2348366 2010-10-26 11:09:46 File_1.txt
-rwxr-xr-x root/root 2383552 2010-10-26 12:52:45 File_2 .txt
-rw-r–r– root/root 89106866 2010-12-20 14:30:01 File_3.txt
The third column of data from the left is the file size (unit : Byte), the sixth column is the file name. If you want to see more clearly, use awk to filter the output:
tar tvf my_file.tar.gz |
Awk ‘{print $3, $6}’
This will only output the 3rd and 6th columns, and the output will look like this:
2348366 File_1.txt
2383552 File_2 .txt
89106866 File_3.txt
If you want to display the file size in KB/MB/GB, you can divide N 1024 by the third column, for example, if you want to display GB, :
tar tvf my_file.tar.gz |
Awk ‘{print $3/1024/1024/1024, $6}’
The number of bytes is divided by 3 1024, which is GB, and the output is like:
0.00218708 File_1.txt
0.00221985 File_2.txt
0.0829872 File_3.txt
If you have a very large file (for example, hundreds of G) and the archive contains many files, this The process will be lengthy, letting shell commands execute in the background, and it is a reasonable practice to output the results to a file, as follows:
nohup tar tvf my_file.tar.gz |
Awk ‘{print $3/1024/1024/1024, $6}& rsquo; 》 /root/result.txt &
nohup guarantees uninterrupted shell commands (secureCRT and other clients when network conditions are poor) The software may interrupt the connection with the server, so that the command has been interrupted before it is executed.) The redirection character is not necessary, and the result is saved to the result.txt file in the /root/directory.
The above is the way to view the file size in the compressed file under Linux. If you don't know how to view the file in the compressed file, you can try the method described in this article, I hope to help you.
Linux Mint is a Linux distribution based on Debian and Ubuntu. It provides a free a
SecureCRT is a terminal emulation software that is used in a variety of systems. Ho
Ifconfig command is mainly used to display configuration network devices in Linux system, and many p
Sysdig is a system debugging tool that can troubleshoot and monitor the system. It is very useful wh
Linux prompts gzip:stdin:not when extracting tar.gz file?
How to use rsa password-free login in Linux
Lubuntu prompts mixed error solutions when using Docky
Linux system expect command operation example
How does Linux use tools to encrypt data?
How to use rz/sz tool for file transfer in Linux
How to use AWK regular expressions under Linux system
Linux system yum command function introduction
How to use Ctags tool to quickly find source code in Linux
How to implement multi-window operation on Linux on Linux
Windows Vista set up broadband connection tutorial
Win7 wireless network display is not connected but can access the Internet
How to change the Win10 boot greeting?
What does the Windows 7 netbook version mean?
Nginx start, stop, restart, upgrade operation command collection
How to use the same account to synchronize applications on different computers under Win8.1
Win7 screen saturation how to adjust
How to replace the computer theme
How to solve the problem that the Win10 system start menu pops up very slowly