How can I know the total size taken by specific kind of files in my hard drive?
Clash Royale CLAN TAG#URR8PPP
I would like to know if there's a command that can tell me how much storage are the .jpg files (for example). Something like if I do find / -iname "*.jpg"
which can add the size of each file found and output a total.
find disk-usage images
add a comment |
I would like to know if there's a command that can tell me how much storage are the .jpg files (for example). Something like if I do find / -iname "*.jpg"
which can add the size of each file found and output a total.
find disk-usage images
Output thefind
results in a file an rundu -s
on its content.
– Julie Pelletier
Jul 2 '16 at 20:05
add a comment |
I would like to know if there's a command that can tell me how much storage are the .jpg files (for example). Something like if I do find / -iname "*.jpg"
which can add the size of each file found and output a total.
find disk-usage images
I would like to know if there's a command that can tell me how much storage are the .jpg files (for example). Something like if I do find / -iname "*.jpg"
which can add the size of each file found and output a total.
find disk-usage images
find disk-usage images
edited Feb 11 at 20:21
Rui F Ribeiro
41.1k1480138
41.1k1480138
asked Jul 2 '16 at 20:03
VaToVaTo
1,8821832
1,8821832
Output thefind
results in a file an rundu -s
on its content.
– Julie Pelletier
Jul 2 '16 at 20:05
add a comment |
Output thefind
results in a file an rundu -s
on its content.
– Julie Pelletier
Jul 2 '16 at 20:05
Output the
find
results in a file an run du -s
on its content.– Julie Pelletier
Jul 2 '16 at 20:05
Output the
find
results in a file an run du -s
on its content.– Julie Pelletier
Jul 2 '16 at 20:05
add a comment |
2 Answers
2
active
oldest
votes
find ./path/to/your/drive -type f -name '*.jpg' -exec du -ch +
Or much faster
find /path/to/your/drive -name "*.jpg" -print0 | du -ch --files0-from=-
Or simply,
du -ch /path/to/your/drive/*.jpg | grep total
Or with help of awk
,
find /path/to/your/drive -iname "*.jpg" -ls | awk 'total += $7 END print total'
On my system file size shows on seventh field, if it's different for you then adjust accordingly.
As requested by OP in comment, if you want to find all images from a directory and total size you can use this command (suggested by @Stéphane Chazelas)
find . -type f -exec file --mime-type + | sed -n 's|: image/[^[:blank:]]*$||p' | tr 'n' '' | du --files0-from=- -hc
Or
du -shc $(find . -name '*' -exec file ; | grep -o -P '^.+: w+ image' | cut -d':' -f1) | grep total
1
That will only give the individual sizes of each file.
– Julie Pelletier
Jul 2 '16 at 20:17
@julipelletier typo corrected
– Rahul
Jul 2 '16 at 20:19
Thank you Rahul, I just wonder how can I make it work with:find . -name '*' -exec file ; | grep -o -P '^.+: w+ image'
which basically looks for all images not just jp*g files.
– VaTo
Jul 2 '16 at 20:39
2
@Saul,find . -type f -exec file --mime-type + | sed -n 's|: image/[^[:blank:]]*$||p' | tr 'n' '' | du --files0-from=- -hc
– Stéphane Chazelas
Jul 2 '16 at 20:46
@Saul see updated answer
– Rahul
Jul 2 '16 at 21:08
|
show 3 more comments
As an alternative, you can do this using only POSIX:
find . -type f -name "*.jpg" -exec du -sk ; |
awk 'BEGINtotal=0;total += $1; ENDprintf "%.3f MBn", total / 1024'
Further reading:
du - estimate file space usage (POSIX)
find - find files (POSIX)
(about;
) That's a POSIX requirement. I tried to have that requirement lifted as I couldn't find any implementation where it was needed, but that was rejected by the gawk maintainer.
– Stéphane Chazelas
Jul 2 '16 at 20:58
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f293499%2fhow-can-i-know-the-total-size-taken-by-specific-kind-of-files-in-my-hard-drive%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
find ./path/to/your/drive -type f -name '*.jpg' -exec du -ch +
Or much faster
find /path/to/your/drive -name "*.jpg" -print0 | du -ch --files0-from=-
Or simply,
du -ch /path/to/your/drive/*.jpg | grep total
Or with help of awk
,
find /path/to/your/drive -iname "*.jpg" -ls | awk 'total += $7 END print total'
On my system file size shows on seventh field, if it's different for you then adjust accordingly.
As requested by OP in comment, if you want to find all images from a directory and total size you can use this command (suggested by @Stéphane Chazelas)
find . -type f -exec file --mime-type + | sed -n 's|: image/[^[:blank:]]*$||p' | tr 'n' '' | du --files0-from=- -hc
Or
du -shc $(find . -name '*' -exec file ; | grep -o -P '^.+: w+ image' | cut -d':' -f1) | grep total
1
That will only give the individual sizes of each file.
– Julie Pelletier
Jul 2 '16 at 20:17
@julipelletier typo corrected
– Rahul
Jul 2 '16 at 20:19
Thank you Rahul, I just wonder how can I make it work with:find . -name '*' -exec file ; | grep -o -P '^.+: w+ image'
which basically looks for all images not just jp*g files.
– VaTo
Jul 2 '16 at 20:39
2
@Saul,find . -type f -exec file --mime-type + | sed -n 's|: image/[^[:blank:]]*$||p' | tr 'n' '' | du --files0-from=- -hc
– Stéphane Chazelas
Jul 2 '16 at 20:46
@Saul see updated answer
– Rahul
Jul 2 '16 at 21:08
|
show 3 more comments
find ./path/to/your/drive -type f -name '*.jpg' -exec du -ch +
Or much faster
find /path/to/your/drive -name "*.jpg" -print0 | du -ch --files0-from=-
Or simply,
du -ch /path/to/your/drive/*.jpg | grep total
Or with help of awk
,
find /path/to/your/drive -iname "*.jpg" -ls | awk 'total += $7 END print total'
On my system file size shows on seventh field, if it's different for you then adjust accordingly.
As requested by OP in comment, if you want to find all images from a directory and total size you can use this command (suggested by @Stéphane Chazelas)
find . -type f -exec file --mime-type + | sed -n 's|: image/[^[:blank:]]*$||p' | tr 'n' '' | du --files0-from=- -hc
Or
du -shc $(find . -name '*' -exec file ; | grep -o -P '^.+: w+ image' | cut -d':' -f1) | grep total
1
That will only give the individual sizes of each file.
– Julie Pelletier
Jul 2 '16 at 20:17
@julipelletier typo corrected
– Rahul
Jul 2 '16 at 20:19
Thank you Rahul, I just wonder how can I make it work with:find . -name '*' -exec file ; | grep -o -P '^.+: w+ image'
which basically looks for all images not just jp*g files.
– VaTo
Jul 2 '16 at 20:39
2
@Saul,find . -type f -exec file --mime-type + | sed -n 's|: image/[^[:blank:]]*$||p' | tr 'n' '' | du --files0-from=- -hc
– Stéphane Chazelas
Jul 2 '16 at 20:46
@Saul see updated answer
– Rahul
Jul 2 '16 at 21:08
|
show 3 more comments
find ./path/to/your/drive -type f -name '*.jpg' -exec du -ch +
Or much faster
find /path/to/your/drive -name "*.jpg" -print0 | du -ch --files0-from=-
Or simply,
du -ch /path/to/your/drive/*.jpg | grep total
Or with help of awk
,
find /path/to/your/drive -iname "*.jpg" -ls | awk 'total += $7 END print total'
On my system file size shows on seventh field, if it's different for you then adjust accordingly.
As requested by OP in comment, if you want to find all images from a directory and total size you can use this command (suggested by @Stéphane Chazelas)
find . -type f -exec file --mime-type + | sed -n 's|: image/[^[:blank:]]*$||p' | tr 'n' '' | du --files0-from=- -hc
Or
du -shc $(find . -name '*' -exec file ; | grep -o -P '^.+: w+ image' | cut -d':' -f1) | grep total
find ./path/to/your/drive -type f -name '*.jpg' -exec du -ch +
Or much faster
find /path/to/your/drive -name "*.jpg" -print0 | du -ch --files0-from=-
Or simply,
du -ch /path/to/your/drive/*.jpg | grep total
Or with help of awk
,
find /path/to/your/drive -iname "*.jpg" -ls | awk 'total += $7 END print total'
On my system file size shows on seventh field, if it's different for you then adjust accordingly.
As requested by OP in comment, if you want to find all images from a directory and total size you can use this command (suggested by @Stéphane Chazelas)
find . -type f -exec file --mime-type + | sed -n 's|: image/[^[:blank:]]*$||p' | tr 'n' '' | du --files0-from=- -hc
Or
du -shc $(find . -name '*' -exec file ; | grep -o -P '^.+: w+ image' | cut -d':' -f1) | grep total
edited Jul 2 '16 at 21:07
answered Jul 2 '16 at 20:10
RahulRahul
9,28212844
9,28212844
1
That will only give the individual sizes of each file.
– Julie Pelletier
Jul 2 '16 at 20:17
@julipelletier typo corrected
– Rahul
Jul 2 '16 at 20:19
Thank you Rahul, I just wonder how can I make it work with:find . -name '*' -exec file ; | grep -o -P '^.+: w+ image'
which basically looks for all images not just jp*g files.
– VaTo
Jul 2 '16 at 20:39
2
@Saul,find . -type f -exec file --mime-type + | sed -n 's|: image/[^[:blank:]]*$||p' | tr 'n' '' | du --files0-from=- -hc
– Stéphane Chazelas
Jul 2 '16 at 20:46
@Saul see updated answer
– Rahul
Jul 2 '16 at 21:08
|
show 3 more comments
1
That will only give the individual sizes of each file.
– Julie Pelletier
Jul 2 '16 at 20:17
@julipelletier typo corrected
– Rahul
Jul 2 '16 at 20:19
Thank you Rahul, I just wonder how can I make it work with:find . -name '*' -exec file ; | grep -o -P '^.+: w+ image'
which basically looks for all images not just jp*g files.
– VaTo
Jul 2 '16 at 20:39
2
@Saul,find . -type f -exec file --mime-type + | sed -n 's|: image/[^[:blank:]]*$||p' | tr 'n' '' | du --files0-from=- -hc
– Stéphane Chazelas
Jul 2 '16 at 20:46
@Saul see updated answer
– Rahul
Jul 2 '16 at 21:08
1
1
That will only give the individual sizes of each file.
– Julie Pelletier
Jul 2 '16 at 20:17
That will only give the individual sizes of each file.
– Julie Pelletier
Jul 2 '16 at 20:17
@julipelletier typo corrected
– Rahul
Jul 2 '16 at 20:19
@julipelletier typo corrected
– Rahul
Jul 2 '16 at 20:19
Thank you Rahul, I just wonder how can I make it work with:
find . -name '*' -exec file ; | grep -o -P '^.+: w+ image'
which basically looks for all images not just jp*g files.– VaTo
Jul 2 '16 at 20:39
Thank you Rahul, I just wonder how can I make it work with:
find . -name '*' -exec file ; | grep -o -P '^.+: w+ image'
which basically looks for all images not just jp*g files.– VaTo
Jul 2 '16 at 20:39
2
2
@Saul,
find . -type f -exec file --mime-type + | sed -n 's|: image/[^[:blank:]]*$||p' | tr 'n' '' | du --files0-from=- -hc
– Stéphane Chazelas
Jul 2 '16 at 20:46
@Saul,
find . -type f -exec file --mime-type + | sed -n 's|: image/[^[:blank:]]*$||p' | tr 'n' '' | du --files0-from=- -hc
– Stéphane Chazelas
Jul 2 '16 at 20:46
@Saul see updated answer
– Rahul
Jul 2 '16 at 21:08
@Saul see updated answer
– Rahul
Jul 2 '16 at 21:08
|
show 3 more comments
As an alternative, you can do this using only POSIX:
find . -type f -name "*.jpg" -exec du -sk ; |
awk 'BEGINtotal=0;total += $1; ENDprintf "%.3f MBn", total / 1024'
Further reading:
du - estimate file space usage (POSIX)
find - find files (POSIX)
(about;
) That's a POSIX requirement. I tried to have that requirement lifted as I couldn't find any implementation where it was needed, but that was rejected by the gawk maintainer.
– Stéphane Chazelas
Jul 2 '16 at 20:58
add a comment |
As an alternative, you can do this using only POSIX:
find . -type f -name "*.jpg" -exec du -sk ; |
awk 'BEGINtotal=0;total += $1; ENDprintf "%.3f MBn", total / 1024'
Further reading:
du - estimate file space usage (POSIX)
find - find files (POSIX)
(about;
) That's a POSIX requirement. I tried to have that requirement lifted as I couldn't find any implementation where it was needed, but that was rejected by the gawk maintainer.
– Stéphane Chazelas
Jul 2 '16 at 20:58
add a comment |
As an alternative, you can do this using only POSIX:
find . -type f -name "*.jpg" -exec du -sk ; |
awk 'BEGINtotal=0;total += $1; ENDprintf "%.3f MBn", total / 1024'
Further reading:
du - estimate file space usage (POSIX)
find - find files (POSIX)
As an alternative, you can do this using only POSIX:
find . -type f -name "*.jpg" -exec du -sk ; |
awk 'BEGINtotal=0;total += $1; ENDprintf "%.3f MBn", total / 1024'
Further reading:
du - estimate file space usage (POSIX)
find - find files (POSIX)
edited Jul 2 '16 at 20:53
answered Jul 2 '16 at 20:43
Thomas DickeyThomas Dickey
53.8k5103176
53.8k5103176
(about;
) That's a POSIX requirement. I tried to have that requirement lifted as I couldn't find any implementation where it was needed, but that was rejected by the gawk maintainer.
– Stéphane Chazelas
Jul 2 '16 at 20:58
add a comment |
(about;
) That's a POSIX requirement. I tried to have that requirement lifted as I couldn't find any implementation where it was needed, but that was rejected by the gawk maintainer.
– Stéphane Chazelas
Jul 2 '16 at 20:58
(about
;
) That's a POSIX requirement. I tried to have that requirement lifted as I couldn't find any implementation where it was needed, but that was rejected by the gawk maintainer.– Stéphane Chazelas
Jul 2 '16 at 20:58
(about
;
) That's a POSIX requirement. I tried to have that requirement lifted as I couldn't find any implementation where it was needed, but that was rejected by the gawk maintainer.– Stéphane Chazelas
Jul 2 '16 at 20:58
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f293499%2fhow-can-i-know-the-total-size-taken-by-specific-kind-of-files-in-my-hard-drive%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Output the
find
results in a file an rundu -s
on its content.– Julie Pelletier
Jul 2 '16 at 20:05