Re: Size of a directory
- From: David Bolt <blacklist-me@xxxxxxxxxx>
- Date: Sat, 26 May 2007 22:22:50 +0100
On Sat, 26 May 2007, John Bowling wrote:-
Henk Oegema wrote:
Is there a command to find the size of all files (together) in a directory ?The responses so far have all been using command line methods.
That's probably because that was what was asked for. Or did Henk really
mean what mouse clicks do I need to use when he asked "Is there a
command..." ?
In Kde, using Konqueror, right click on the directory and it will show
the total size in both MB and bytes.
Well, if you select "Properties" from the pop-up menu it will.
For a lot of things manipulating directories I use Kde. There are
problems moving directories with command lines (probably because I never
looked up the options to do it right)
Most likely. It's not that hard to use "man mv" or "mv --help" .
- mv will not create new
directories at the new location by default.
It won't? It will here.
<snippet>
davjam@playing:~> ls -lR mnt
mnt:
total 11876
-rw-r--r-- 1 davjam users 382981 2003-10-16 06:47 fron_msa.zip
-rw-r--r-- 1 davjam users 384960 2003-10-16 06:47 fron_st.zip
-rw-r--r-- 1 davjam users 380328 2003-10-16 06:47 frontier.zip
-rw-r----- 1 davjam users 24973 2003-10-16 06:47 list.txt
drwxr-xr-x 2 davjam users 4096 2003-10-16 06:47 samba
drwxr-xr-x 2 davjam users 4096 2007-05-26 21:32 tags4-1.0.0
-rw-r----- 1 davjam users 3585775 2003-10-16 06:48 tar-1.tar.gz
-rw-r----- 1 davjam users 513287 2003-10-16 06:48 tar-2.tar.gz
-rw-r----- 1 davjam users 1683989 2003-10-16 06:48 tar-3.tar.gz
-rw-r----- 1 davjam users 5140322 2003-10-16 06:48 tar-4.tar.gz
drwxr-xr-x 2 davjam users 4096 2007-05-26 21:33 text
mnt/samba:
total 0
mnt/tags4-1.0.0:
total 88
-rwxr--r-- 1 davjam users 888 2007-05-26 21:32 each_file.c
-rw-r--r-- 1 davjam users 3176 2007-05-26 21:32 each_file.o
-rwxr--r-- 1 davjam users 714 2007-05-26 21:32 lame_it.c
-rw-r--r-- 1 davjam users 3688 2007-05-26 21:32 lame_it.o
-rwxr--r-- 1 davjam users 311 2007-05-26 21:32 Makefile
-rwxr--r-- 1 davjam users 1525 2007-05-26 21:32 read_tag.c
-rw-r--r-- 1 davjam users 4448 2007-05-26 21:32 read_tag.o
-rwxr--r-- 1 davjam users 312 2007-05-26 21:32 shrink.c
-rw-r--r-- 1 davjam users 1384 2007-05-26 21:32 shrink.o
-rwxr-xr-x 1 davjam users 17899 2007-05-26 21:32 tags4
-rwxr--r-- 1 davjam users 1555 2007-05-26 21:32 tags4.c
-rwxr--r-- 1 davjam users 1939 2007-05-26 21:32 tags4.h
-rw-r--r-- 1 davjam users 5896 2007-05-26 21:32 tags4.o
-rwxr--r-- 1 davjam users 1414 2007-05-26 21:32 upper_case.c
-rw-r--r-- 1 davjam users 6712 2007-05-26 21:32 upper_case.o
mnt/text:
total 0
davjam@playing:~> mv -v mnt/tags4-1.0.0 mnt/text/new_dir
`mnt/tags4-1.0.0' -> `mnt/text/new_dir'
davjam@playing:~> ls -lR mnt
mnt:
total 11872
-rw-r--r-- 1 davjam users 382981 2003-10-16 06:47 fron_msa.zip
-rw-r--r-- 1 davjam users 384960 2003-10-16 06:47 fron_st.zip
-rw-r--r-- 1 davjam users 380328 2003-10-16 06:47 frontier.zip
-rw-r----- 1 davjam users 24973 2003-10-16 06:47 list.txt
drwxr-xr-x 2 davjam users 4096 2003-10-16 06:47 samba
-rw-r----- 1 davjam users 3585775 2003-10-16 06:48 tar-1.tar.gz
-rw-r----- 1 davjam users 513287 2003-10-16 06:48 tar-2.tar.gz
-rw-r----- 1 davjam users 1683989 2003-10-16 06:48 tar-3.tar.gz
-rw-r----- 1 davjam users 5140322 2003-10-16 06:48 tar-4.tar.gz
drwxr-xr-x 3 davjam users 4096 2007-05-26 21:34 text
mnt/samba:
total 0
mnt/text:
total 4
drwxr-xr-x 2 davjam users 4096 2007-05-26 21:32 new_dir
mnt/text/new_dir:
total 88
-rwxr--r-- 1 davjam users 888 2007-05-26 21:32 each_file.c
-rw-r--r-- 1 davjam users 3176 2007-05-26 21:32 each_file.o
-rwxr--r-- 1 davjam users 714 2007-05-26 21:32 lame_it.c
-rw-r--r-- 1 davjam users 3688 2007-05-26 21:32 lame_it.o
-rwxr--r-- 1 davjam users 311 2007-05-26 21:32 Makefile
-rwxr--r-- 1 davjam users 1525 2007-05-26 21:32 read_tag.c
-rw-r--r-- 1 davjam users 4448 2007-05-26 21:32 read_tag.o
-rwxr--r-- 1 davjam users 312 2007-05-26 21:32 shrink.c
-rw-r--r-- 1 davjam users 1384 2007-05-26 21:32 shrink.o
-rwxr-xr-x 1 davjam users 17899 2007-05-26 21:32 tags4
-rwxr--r-- 1 davjam users 1555 2007-05-26 21:32 tags4.c
-rwxr--r-- 1 davjam users 1939 2007-05-26 21:32 tags4.h
-rw-r--r-- 1 davjam users 5896 2007-05-26 21:32 tags4.o
-rwxr--r-- 1 davjam users 1414 2007-05-26 21:32 upper_case.c
-rw-r--r-- 1 davjam users 6712 2007-05-26 21:32 upper_case.o
</snippet>
That's on the same file-system. Here the source directory was simply
renamed. It's slightly different when the source and destination are
different file-systems:
<snippet>
davjam@playing:~> mv -v mnt/tags4-1.0.0 /local1
`mnt/tags4-1.0.0' -> `/local1/tags4-1.0.0'
`mnt/tags4-1.0.0/each_file.c' -> `/local1/tags4-1.0.0/each_file.c'
`mnt/tags4-1.0.0/Makefile' -> `/local1/tags4-1.0.0/Makefile'
`mnt/tags4-1.0.0/tags4.o' -> `/local1/tags4-1.0.0/tags4.o'
`mnt/tags4-1.0.0/each_file.o' -> `/local1/tags4-1.0.0/each_file.o'
`mnt/tags4-1.0.0/lame_it.c' -> `/local1/tags4-1.0.0/lame_it.c'
`mnt/tags4-1.0.0/shrink.o' -> `/local1/tags4-1.0.0/shrink.o'
`mnt/tags4-1.0.0/read_tag.c' -> `/local1/tags4-1.0.0/read_tag.c'
`mnt/tags4-1.0.0/upper_case.o' -> `/local1/tags4-1.0.0/upper_case.o'
`mnt/tags4-1.0.0/shrink.c' -> `/local1/tags4-1.0.0/shrink.c'
`mnt/tags4-1.0.0/read_tag.o' -> `/local1/tags4-1.0.0/read_tag.o'
`mnt/tags4-1.0.0/tags4.c' -> `/local1/tags4-1.0.0/tags4.c'
`mnt/tags4-1.0.0/tags4.h' -> `/local1/tags4-1.0.0/tags4.h'
`mnt/tags4-1.0.0/tags4' -> `/local1/tags4-1.0.0/tags4'
`mnt/tags4-1.0.0/upper_case.c' -> `/local1/tags4-1.0.0/upper_case.c'
`mnt/tags4-1.0.0/lame_it.o' -> `/local1/tags4-1.0.0/lame_it.o'
removed `mnt/tags4-1.0.0/each_file.c'
removed `mnt/tags4-1.0.0/Makefile'
removed `mnt/tags4-1.0.0/tags4.o'
removed `mnt/tags4-1.0.0/each_file.o'
removed `mnt/tags4-1.0.0/lame_it.c'
removed `mnt/tags4-1.0.0/shrink.o'
removed `mnt/tags4-1.0.0/read_tag.c'
removed `mnt/tags4-1.0.0/upper_case.o'
removed `mnt/tags4-1.0.0/shrink.c'
removed `mnt/tags4-1.0.0/read_tag.o'
removed `mnt/tags4-1.0.0/tags4.c'
removed `mnt/tags4-1.0.0/tags4.h'
removed `mnt/tags4-1.0.0/tags4'
removed `mnt/tags4-1.0.0/upper_case.c'
removed `mnt/tags4-1.0.0/lame_it.o'
removed directory: `mnt/tags4-1.0.0'
</snippet>
As you can see, in this situation, mv creates the destination directory,
copies the contents from the source to the destination, then deletes the
files/directories from the source.
rm and rmdir have problems
when there are hundreds of files to delete.
I don't know about rmdir, since I've never used it. I have used rm and,
unless you pass a wildcard ('*' is a good one) in a directory with lots
of files/directories, it manages quite well:
<snippet>
davjam@playing:~> mkdir -p /local1/tags
davjam@playing:~> mv -f /local1/tags4-1.0.0/ /local1/tags/
davjam@playing:~> for i in $(seq 1 1000) ; do cp -r ~/tags4-1.0.0 $(printf "/local1/tags/tags4-1.0.0-%04u" $i) ; done
davjam@playing:~> find /local1/tags | wc -l
16017
davjam@playing:~> rm -rf /local1/tags
davjam@playing:~>
</snippet>
Nope. Handled that easily. How about with a wildcard?
<snippet>
davjam@playing:~> cp -r tags4-1.0.0 /local1/tags
davjam@playing:~> for i in $(seq 1 1000) ; do cp -r ~/tags4-1.0.0 $(printf "/local1/tags/tags4-1.0.0-%04u" $i) ; done
davjam@playing:~> find /local1/tags | wc -l 16016
davjam@playing:~> rm -rf /local1/tags/* davjam@playing:~>
</snippet>
Well that went okay, but then there was only 1014 filenames passed. How
about several thousand more?
<snippet>
davjam@playing:~> cp -r tags4-1.0.0 /local1/tags davjam@playing:~> for i in $(seq 1 5000) ; do cp -r
davjam@playing:~> for i in $(seq 1 5000) ; do cp -r ~/tags4-1.0.0 $(printf "/local1/tags/tags4-1.0.0-%04u" $i) ; done
davjam@playing:~> find /local1/tags | wc -l 80017
davjam@playing:~> rm -rf /local1/tags/* -bash: /bin/rm: Argument list too long
-bash: /bin/rm: Argument list too long
davjam@playing:~>
</snippet>
Ah, now it's failed with 5014 filenames. Okay, lets reduce that a touch
and see what happens:
<snippet>
davjam@playing:~> rm -rf /local1/tags/*[54]???
davjam@playing:~> rm -rf /local1/tags/*
davjam@playing:~>
</snippet>
Well, dropping it down to 3013 filenames got rid of them all without
another error.
And Konqueror does all of
these without blinking.
In the case of mv, I'll disagree with you, but in the case of rm I will
sort of agree. KDE handles the rm a lot easier, but I don't agree that
it "does all of these without blinking."
mv will create the destination directory if what you're moving is a
directory. It won't create any missing directories, so you couldn't use:
mv /home/<USER>/source /home/<USER>/missing_dir1/missing_dir2/dest
You can't do that sort of move in KDE either. While, using the
command-line you could use:
mkdir -p /home/<USER>/missing_dir1/missing_dir2
to create the missing directories, then use the mv command, to do the
same in KDE would require opening a window for the destination, creating
the directory missing_dir1, changing into that directory, then create
missing_dir2, then you could drag the source file to destination. And if
you want source to be renamed as dest, you've got to either right-click
and select rename, or highlight it and then press F2.
So, which do you think is going to be the quicker? As a "two-fingered"
typist, I know which one is quicker for me, and it'd not the one that
requires mouse clicks.
Regards,
David Bolt
--
Member of Team Acorn checking nodes at 50 Mnodes/s: http://www.distributed.net/
RISCOS 3.11 | SUSE 10.0 32bit | SUSE 10.1 32bit | openSUSE 10.2 32bit
RISCOS 3.6 | SUSE 10.0 64bit | SUSE 10.1 64bit | openSUSE 10.2 64bit
TOS 4.02 | SUSE 9.3 32bit | | openSUSE 10.3a4 32bit
.
- Follow-Ups:
- Re: Size of a directory
- From: John Bowling
- Re: Size of a directory
- References:
- Size of a directory
- From: Henk Oegema
- Re: Size of a directory
- From: John Bowling
- Size of a directory
- Prev by Date: Re: YouTube lockup in Firefox
- Next by Date: Re: YouTube lockup in Firefox
- Previous by thread: Re: Size of a directory
- Next by thread: Re: Size of a directory
- Index(es):
Relevant Pages
|