10 More Discussions You Might Find Interesting
1. UNIX for Beginners Questions & Answers
I am new to Unix and need help. I have several files of different sizes Example: 1 GB , 2GB , 500 mb ,200mb and even small sizes. What I want is I want to pick files and sum of the combined file size should be less than 3 Gb and move them to a different directory. when I do ls -ltr I want... (5 Replies)
Discussion started by: pyarigreat
5 Replies
2. Shell Programming and Scripting
Hello,
I want remove files have same size in a directory.
this command only find this files.
ls -l | awk '$1!~/^d/{if(size!=""){ print}size=$8}'
I want to remove the files of the same size.
samples: 5 files are same size. I want to keep only first file.
Thank you very much for your help. (3 Replies)
Discussion started by: hoo
3 Replies
3. Shell Programming and Scripting
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
4. UNIX for Dummies Questions & Answers
Hi guys,
I need to do 100 files comparison after I sorted the files. There are no specific key for sorting so i plan to arrange the files based on the file size. The command that i used to sort the files by size is as per below:-
ls -l | sort +4rn | awk '{print $5, $9}'
The problem that i... (3 Replies)
Discussion started by: shahril
3 Replies
5. UNIX for Dummies Questions & Answers
hello
i would like to copy files from 1 location to a nother, but it has only to copy files which are newer or have a different filesize.
all has to be logged to a copy.log file (als skipped files should be in the log)
is this possible with the cp command (1 Reply)
Discussion started by: arnoldg
1 Replies
6. Shell Programming and Scripting
hi,
i am facing a problem in merging two files using awk,
the problem is as stated below,
file1:
A|B|C|D|E|F|G|H|I|1
M|N|O|P|Q|R|S|T|U|2
AA|BB|CC|DD|EE|FF|GG|HH|II|1
....
....
....
file2 :
1|Mn|op|qr (2 Replies)
Discussion started by: shashi1982
2 Replies
7. Shell Programming and Scripting
Basic:
find . -type f -name “*.txt” -print | awk '{gsub("Ontem", "AntesdeOntem", $0); print > FILENAME}' *.txt
The idea is in folder /home/myapontamentos
I have some files and i need to change in all them the word "ontem" to "antesdeontem".
But bigger files are cut (size i mean)... (4 Replies)
Discussion started by: single
4 Replies
8. Shell Programming and Scripting
hello Experts,can any one tell me that i have a folder data in linux.
and there are three files A,B,C in the directory.
cany any one tell me the command that which can tell me how much space is occupied by each file and its free space also
for example
FILES USED SPACE FREE SPACE
A ... (1 Reply)
Discussion started by: shary
1 Replies
9. Shell Programming and Scripting
Hi,
I have one file stat.
Stat file contents are as follows: for example.
H50768020040913,00260100,507680,13,0000000643,0000000643,00000,0000
H50769520040808,00260100,507695,13,0000000000,0000000000,00000,0000 H50770620040611,00260100,507706,13,0000000000,0000000000,00000,0000
Now i... (1 Reply)
Discussion started by: davidpreml
1 Replies
10. UNIX for Dummies Questions & Answers
Is there a way to sort files by size using the ls command?
thanks in advance (1 Reply)
Discussion started by: AMD
1 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)