So it fits precisely du with the –files0-from=- option. find‘s -print0 action prints each filename followed by a null character. find -iname '.zip' -size + ( (6010241024))c -size - ( (7010241024))c. So if we want du to process the filenames found by the find command, we can use the -print0 action. It is a sparse file (mostly zeros that are not actually written to disk but represented as logical 'holes' in the file). This means that this is a 512 MB file that takes about 24 KB on disk. This will give the same number as du -B 1 for the file. We’ve seen that the find command prints each file’s name with a newline character. With GNU ls, you may also do ls -s -block-size1 on the file. This is pretty useful if we pipe a bunch of filenames to the du command. ![]() Further, the filenames should be terminated by a null character. It’s worth mentioning that when F is –, du reads filenames from stdin. Instead of passing filenames directly to the du command, we can use the –files0-from=F option to tell du to read filenames from the F file. We know that the du command with the -b option reports the given files or directories size in bytes, for example: $ du -b myDir/picture01.jpgĪdditionally, we can add the -c option to make du sum up the file sizes for all files we pass to it: $ du -bc myDir/*.jpg However, we need to type the awk command whenever we want to sum up the filesizes in the ls output. ![]() ![]() A compact awk one-liner solves our problem. To achieve that, we can pipe the ls -l output to the awk command: $ ls -l *.* | awk ''Īs we can see, the total size (in bytes) of the listed files is calculated and printed. Use du -h For check all folder size of current directory. Now that we understand the ls -l output, if we want to sum the file sizes in the ls -l list, we need to sum the fifth column (file size in bytes) in each file record. Use df -h For check out the used space, free space and total space From all the partitions. | | | | | | +- The last modification time Let’s take the 001.txt file as an example to understand the ls -l output: -rw-r-r- 1 kent kent 2 Dec 9 13:20 001.txt
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |