Sponsored Content
Full Discussion: directory size with ls -l
Top Forums UNIX for Dummies Questions & Answers directory size with ls -l Post 302169519 by jim mcnamara on Thursday 21st of February 2008 01:57:43 PM
Old 02-21-2008
ls -l on a directory gives the size of the directory file - the place where file metadata lives.

without resorting C code try:
Code:
du . | awk '{sum+=$1} END {printf("%12.0f\n", sum*512)}'

The . is the current working directory, this gives usage from there on down.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Size of a directory

Hi, It would be of great help if anyone can tell me what is the command for getting the size of a directory. Thx a lot in advance Minaz (9 Replies)
Discussion started by: minazk
9 Replies

2. UNIX for Dummies Questions & Answers

size of a directory?

hi, say i have the following directory structure a/b/c/d... can i do df -kt /a/b/c/d and the output will gives me the total space of the directory space in d? or the output will just be the total space of the parent directory a. hope its clear.. (2 Replies)
Discussion started by: yls177
2 Replies

3. Programming

size of a directory

hai friends I need a program to find the size of a directory.. When i tried to get the size, it always gives the default space allocated for it. How can i findout the exact size of a directory using a c program Thanks in advance Collins (6 Replies)
Discussion started by: collins
6 Replies

4. AIX

size of directory with ls -l

hello When i do a "ls -l" in a directory (Aix 5.3), i have the result : >ls -l total 65635864 -rw-r--r-- 1 lobi system 2559909888 Feb 20 15:06 cible5.7bdat -rw-r--r-- 1 lobi system 1020098870 Feb 20 13:06 cible6.7bdat -rw-r--r-- 1 lobi system 1544789511 Feb 20 11:06 cible9.7bdat -rw-r--r--... (2 Replies)
Discussion started by: pascalbout
2 Replies

5. Shell Programming and Scripting

size of directory

Hello again; I have a directories and subdirectories in my current directory and i wanna to find the directories( and subdirectories ) which are larger than what user enters as first parameter. find . -type d -size +"$1"c -print > directories.dat I used this command and i am not sure it is... (19 Replies)
Discussion started by: redbeard_06
19 Replies

6. Solaris

Directory size larger than file system size?

Hi, We currently have an Oracle database running and it is creating lots of processes in the /proc directory that are 1000M in size. The size of the /proc directory is now reading 26T. How can this be if the root file system is only 13GB? I have seen this before we an Oracle temp file... (6 Replies)
Discussion started by: sparcman
6 Replies

7. UNIX for Dummies Questions & Answers

directory tree with directory size

find . -type d -print 2>/dev/null|awk '!/\.$/ {for (i=1;i<NF;i++){d=length($i);if ( d < 5 && i != 1 )d=5;printf("%"d"s","|")}print "---"$NF}' FS='/' Can someone explain how this works..?? How can i add directory size to be listed in the above command's output..?? (1 Reply)
Discussion started by: vikram3.r
1 Replies

8. Solaris

get directory size

Hi, How to get size of particular directory? Thanks (5 Replies)
Discussion started by: cutefriend
5 Replies

9. Shell Programming and Scripting

How to delete some of the files in the directory, if the directory size limits the specified size

To find the whole size of a particular directory i use "du -sk /dirname".. but after finding the direcory's size how do i make conditions like if the size of the dir is more than 1 GB i hav to delete some of the files inside the dir (0 Replies)
Discussion started by: shaal89
0 Replies

10. UNIX for Dummies Questions & Answers

Ls directory size reporting byte size instead of file count

I have been searching both on Unix.com and Google and have not been able to find the answer to my question. I think it is partly because I can't come up with the right search terms. Recently, my virtual server switched storage devices and I think the problem may be related to that change.... (2 Replies)
Discussion started by: jmgibby
2 Replies
du(1)								   User Commands							     du(1)

NAME
du - summarize disk usage SYNOPSIS
/usr/bin/du [-dorx] [-a | -s] [-h | -k | -m] [-H | -L] [file ...] /usr/xpg4/bin/du [-dorx] [-a | -s] [-h | -k | -m] [-H | -L] [file ...] DESCRIPTION
The du utility writes to standard output the size of the file space allocated to, and the size of the file space allocated to each subdi- rectory of, the file hierarchy rooted in each of the specified files. The size of the file space allocated to a file of type directory is defined as the sum total of space allocated to all files in the file hierarchy rooted in the directory plus the space allocated to the directory itself. This sum will include the space allocated to any extended attributes encountered. Files with multiple links will be counted and written for only one entry. The directory entry that is selected in the report is unspeci- fied. By default, file sizes are written in 512-byte units, rounded up to the next 512-byte unit. /usr/xpg4/bin/du When du cannot obtain file attributes or read directories (see stat(2)), it will report an error condition and the final exit status will be affected. OPTIONS
The following options are supported for /usr/bin/du and /usr/xpg4/bin/du: -a In addition to the default output, report the size of each file not of type directory in the file hierarchy rooted in the specified file. Regardless of the presence of the -a option, non-directories given as file operands will always be listed. -d Do not cross filesystem boundaries. For example, the command, du -d / reports usage only on the root partition. -h All sizes are scaled to a human readable format, for example, 14K, 234M, 2.7G, or 3.0T. Scaling is done by repetitively dividing by 1024. -H If a symbolic link to a directory is specified on the command line, process the symbolic link by using the directory which the sym- bolic link references, rather than the link itself. -k Write the files sizes in units of 1024 bytes, rather than the default 512-byte units. -L Process symbolic links by using the file or directory which the symbolic link references, rather than the link itself. -m Write the files sizes in units of megabytes, rather than the default 512-byte units. -o Do not add child directories' usage to a parent's total. Without this option, the usage listed for a particular directory is the space taken by the files in that directory, as well as the files in all directories beneath it. This option does nothing if -s is used. -r Generate diagnostic messages about unreadable directories and files whose status cannot be obtained. /usr/bin/du is silent if these conditions arise and -r is not specified. /usr/xpg4/bin/du acts as though -r is always specified. -s Instead of the default output, report only the total sum for each of the specified files. -x When evaluating file sizes, evaluate only those files that have the same device as the file specified by the file operand. Specifying more than one of the options in the mutually exclusive pair, -H and -L, is not considered an error. The last option specified determines the output format. Specifying more than one of the options in the mutually exclusive set of options -h, -k, and -m is not considered an error. The last option specified determines the output format. OPERANDS
The following operand is supported: file The path name of a file whose size is to be written. If no file is specified, the current directory is used. OUTPUT
The output from du consists of the amount of the space allocated to a file and the name of the file. USAGE
See largefile(5) for the description of the behavior of du when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes). ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of du: LANG, LC_ALL, LC_CTYPE, LC_MES- SAGES, and NLSPATH. EXIT STATUS
The following exit values are returned: 0 Successful completion. >0 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: /usr/bin/du +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ |Interface Stability |Stable | +-----------------------------+-----------------------------+ /usr/xpg4/bin/du +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWxcu4 | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
ls(1), stat(2), attributes(5), environ(5), fsattr(5), largefile(5), standards(5) System Administration Guide: Basic Administration NOTES
A file with two or more links is counted only once. If, however, there are links between files in different directories where the directo- ries are on separate branches of the file system hierarchy, du will count the excess files more than once. Files containing holes will result in an incorrect block count. SunOS 5.11 6 Feb 2007 du(1)
All times are GMT -4. The time now is 11:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy