i want to find the total space used for the files owned by me from my current directory.

i have

du -sh `find ./ -user $USER -type f`

which gives

8.0K    ./.a
8.0K    ./t
4.0K    ./cat/A
4.0K    ./a

using -s has no effect.

using du -sh by itself includes the space for files not owned by me and also includes space used by folders themselves.

I want to be able to add all of the above and displayed in readable format automatically.

At this stage i am happy to include the space used for folders or not, doesnt matter.

Any tips would be appreciated.

Recommended Answers

All 2 Replies

hi,

from du --help :

-s, --summarize display only a total **for each argument**

so, as each given filename is an argument...

find's -printf can print files size.
you could use bash to sum files size like this:

echo $(( $(find . -type f -user $USER -printf '+%s') ))"

thanks Watael.

after looking at help i saw -c then used a pipe.

du -ch find ./ -user $USER -type f | tail -n 1

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.