show how much diskspace do certain files use
I have a single file we'll call "SRC"
this "SRC" file contains a long list of files on "server A" that I need to copy to "server B". I don't have much space left on "server B". SO, I need to know how much disk space these files are using. the format of the "SRC" file is.... /path/to/dir1/file1 /path/to/dir1/file2 /path/to/dir2/file3 /path/to/dir3/file4 Please advise on how this can be done either through a simple cmd or script. Thanks. |
use du command to know each file size ...
for example you want to know size of a folder and its subfolders Code:
$du foldername Code:
raju@Raju:~> du Documents If you want to know size of a single file Code:
$du filename Code:
raju@Raju:~/Documents> du His* |
If you are just going to replicate the file tree in whole and need only the total size in bytes:
Code:
(cat SRC|while read f;do du -B1 "$f";done|awk '{t+=$1;}END{print t;}') Code:
(cat SRC|while read f;do du -B1024 "$f";done|awk '{t+=$1;}END{print t;}') Note that these sizes will reflect allocated sizes. If any files are "sparse" (that means any blocks of all bits being zero is just not allocated), the actual allocated size will be small, and a copy operation without a sparse option enabled would make the new files larger. If you are doing the copy with the "cp" command then you should use the "--sparse=always" option. How are you planning to do the file copying? |
You may want to search for a tool called "ncdu"
|
I was going to use this script to copy the files listed in the SRC file.
Code:
#/bin/bash one other thing, you said it will take a while. this SRC file has just over 43,000 files listed. it will be reading from the nfs, so that shouldn't be too bad.....right? i jsut want to make sure I have enough room before I start copying all these files in the SRC list over. thanks. |
All times are GMT -5. The time now is 02:13 PM. |