du

how to get size of folder including apparent size of sparse files? (du is too slow)

廉价感情. 提交于 2019-12-10 15:26:24
问题 I have a folder containing a lot of KVM qcow2 files, they are all sparse files. Now I need to get the total size of folder, the qcow2 file size should be counted as apparent size(not real size). for example: image: c9f38caf104b4d338cc1bbdd640dca89.qcow2 file format: qcow2 virtual size: 100G (107374182400 bytes) disk size: 3.3M cluster_size: 65536 the image should be treated as 100G but not 3.3M originally I use statvfs() but it can only return real size of the folder. then I switch to 'du -

Linux查看磁盘空间

微笑、不失礼 提交于 2019-12-10 04:03:15
##df命令 使用 df -h 命令可以查看磁盘各分区大小、已使用空间以及挂载点等信息. ##du命令 使用 du 命令可以查看某个目录所占用的磁盘空间大小。常见的用法是: du -sh folder. 来源: oschina 链接: https://my.oschina.net/u/941605/blog/726119

linux 查看磁盘信息

若如初见. 提交于 2019-12-06 12:12:42
more /proc/partitions 查看所有分区信息 more /proc/scsi 查看scsi设备(移动硬盘或U盘)信息 more /proc/diskstats 查看磁盘io信息 查看文件占用的内存: 当磁盘大小超过标准时会有报警提示,这时如果掌握df和du命令是非常明智的选择。 df可以查看一级文件夹大小、使用比例、档案系统及其挂入点,但对文件却无能为力。 du可以查看文件及文件夹的大小。 两者配合使用,非常有效。比如用df查看哪个一级目录过大,然后用df查看文件夹或文件的大小,如此便可迅速确定症结。 [yayug@yayu ~]$ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 3.9G 300M 3.4G 8% / /dev/sda7 100G 188M 95G 1% /data0 /dev/sdb1 133G 80G 47G 64% /data1 /dev/sda6 7.8G 218M 7.2G 3% /var /dev/sda5 7.8G 166M 7.2G 3% /tmp /dev/sda3 9.7G 2.5G 6.8G 27% /usr tmpfs 2.0G 0 2.0G 0% /dev/shm 参数 -h 表示使用「Human-readable」的输出,也就是在档案系统大小使用 GB

Why du or echo pipelining is not working?

我只是一个虾纸丫 提交于 2019-12-06 02:13:46
问题 I'm trying to use du command for every directory in the current one. So I'm trying to use code like this: ls | du -sb But its not working as expected. It outputs only size of current '.' directory and thats all. The same thing is with echo ls | echo Outputs empty line. Why is this happening? 回答1: Using a pipe sends the output ( stdout ) of the first command, to stdin (input) of the child process (2nd command). The commands you mentioned don't take any input on stdin . This would work, for

Excluding hidden files from du command output with --exclude, grep -v or sed

此生再无相见时 提交于 2019-12-04 16:06:49
问题 I'm trying to check with Disk Usage tool how big are my home directory folders but it also prints out folders and files starting with dot. I can't seem to filter them out. du -h --exclude="?" du -h | grep -v "?" du -h | grep -ve "?" du -h | sed "?" Thanks in advance. edit> Thank you SiegeX for you answer. du -h --max-depth=1 | grep -v "./\\." Since dot matches any character we have to prefix it with double backslash since its also a special character. 回答1: If running du with no specified path

Why du or echo pipelining is not working?

删除回忆录丶 提交于 2019-12-04 06:48:20
I'm trying to use du command for every directory in the current one. So I'm trying to use code like this: ls | du -sb But its not working as expected. It outputs only size of current '.' directory and thats all. The same thing is with echo ls | echo Outputs empty line. Why is this happening? FatalError Using a pipe sends the output ( stdout ) of the first command, to stdin (input) of the child process (2nd command). The commands you mentioned don't take any input on stdin . This would work, for example, with cat (and by work, I mean work like cat run with no arguments, and just pass along the

Excluding hidden files from du command output with --exclude, grep -v or sed

自闭症网瘾萝莉.ら 提交于 2019-12-03 10:11:45
I'm trying to check with Disk Usage tool how big are my home directory folders but it also prints out folders and files starting with dot. I can't seem to filter them out. du -h --exclude="?" du -h | grep -v "?" du -h | grep -ve "?" du -h | sed "?" Thanks in advance. edit> Thank you SiegeX for you answer. du -h --max-depth=1 | grep -v "./\\." Since dot matches any character we have to prefix it with double backslash since its also a special character. If running du with no specified path (current dir), use this: du -h --exclude "./.*" 来源: https://stackoverflow.com/questions/5463884/excluding

Fast(er) way to get folder size with batch script

女生的网名这么多〃 提交于 2019-12-01 20:09:24
PLEASE SEE BELOW THE ORIGINAL QUESTION FOR SOME TEST COMPARISONS OF DIFFERENT WAYS: So I tried 2 ways so far: 1.Iterate through directory using the code from Get Folder Size from Windows Command Line : @echo off set size=0 for /r %%x in (folder\*) do set /a size+=%%~zx echo %size% Bytes 2.Save output of a 'dir %folder% /s /a' into a text file, and then read in the size at the bottom 3.The last way I am trying right now is using du (disk utility tool from MS - https://technet.microsoft.com/en-us/sysinternals/bb896651.aspx ). Now with exception of #3 both of those ways seem way too slow for what

Why does “find . -name *.txt | xargs du -hc” give multiple totals?

前提是你 提交于 2019-11-30 09:45:06
I have a large set of directories for which I'm trying to calculate the sum total size of several hundred .txt files. I tried this, which mostly works: find . -name *.txt | xargs du -hc But instead of giving me one total at the end, I get several. My guess is that the pipe will only pass on so many lines of find's output at a time, and du just operates on each batch as it comes. Is there a way around this? Thanks! Alex How about using the --files0-from option to du? You'd have to generate the null-terminated file output appropriately: find . -name "*txt" -exec echo -n -e {}"\0" \; | du -hc -

Exclude all permission denied messages from “du”

不羁的心 提交于 2019-11-30 01:17:13
I am trying to evaluate the disk usage of a number of Unix user accounts. Simply, I am using the following command: du -cBM --max-depth=1 | sort -n But I’ve seen many error message like below. How can I exclude all such “Permission denied” messages from display? du: `./james/.gnome2': Permission denied My request could be very similar to the following list, by replacing “find” to “du”. How can I exclude all "permission denied" messages from "find"? The following thread does not work. I guess I am using bash. Excluding hidden files from du command output with --exclude, grep -v or sed du -cBM -