Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Unix shell script for finding top ten files of maximum size Post 302167479 by sb008 on Thursday 14th of February 2008 02:19:30 PM
Old 02-14-2008
Quote:
Originally Posted by maheshwin
ls -l will give the output of the total directory links , so dont trust it, du is the exact form to get the info, above commands are perfectly true

-rw-rw-rw- 1 pnt pf 87843360 Feb 6 02:21 /pfta02/10.001

Type of file: - (regular)
Access permission: rw-rw-rw- (readable/writable for everyone)
(Directory) links: 1 (usually 1 for a regular file, unless there are hard links)
owner: prt
group: pf
actual size: 87843360
date of last modification: Feb 6 02:21
filenaam: /pfta02/10.001

So the difference in size has nothing to do with the number of directory links, which is 1 in this case.


The "du" command, without options, reports the size in full disk blocks (usually 512 bytes) allocated by the file, where "ls -l" reports the size of the effective data in the file.

For each file at least 1 full disk block is allocated (actually 2 disk blocks), even of it contains just 1 byte of data.

Files always allocate space in full disk blocks.

Since the "du" commands reports in disk blocks, the result will always be a little bit more than the size reported by "ls -l".

The size of the file = 87843360 bytes
To store this amount of bytes at least 87843360/512 = 171569,0625 disk blocks are needed.

Rounded this would be 171570 full disk blocks. At least 1 extra block is needed, which makes it 171571.

The "du" command reports a size of 171572 blocks which is still 1 block more.

This means the file is most likely split up in 2 fragments.

Where the last block in each segment is not fully filled.
 

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

top ten utilities in shell scripting?

Let's get some feedback about the top ten ute's you guys use in writing your scripts - I mean yeah it depends on the job and what you're trying to accomplish, but there ARE those commands (sed, grep, awk, cut, etc.) that most will use time and again... ...so, what do you use? (3 Replies)
Discussion started by: diego
3 Replies

2. Shell Programming and Scripting

finding duplicate files by size and finding pattern matching and its count

Hi, I have a challenging task,in which i have to find the duplicate files by its name and size,then i need to take anyone of the file.Then i need to open the file and find for more than one pattern and count of that pattern. Note:These are the samples of two files,but i can have more... (2 Replies)
Discussion started by: jerome Sukumar
2 Replies

3. UNIX for Dummies Questions & Answers

Maximum size of a file in unix

What's the maximum file size supported by unix. (3 Replies)
Discussion started by: nagalenoj
3 Replies

4. Shell Programming and Scripting

Display top ten directories by size

Hi, I am new to Unix. I want to display top 10 folders by size. I tried with du -ksl * | sort -nr | head -10 command .But I am getting the following error -bash: /usr/bin/du: Argument list too long Can some one help me. Thanks. (5 Replies)
Discussion started by: Satyak
5 Replies

5. Shell Programming and Scripting

shell script to auto process ten random files and generate logs

Hello member's I'm learning to script in the ksh environment on a Solaris Box. I have 10 files in a directory that I need to pass, as input to a batch job one by one. lets say, the files are named as follows: abcd.txt ; efgh.bat ; wxyz.temp etc. (random filenames with varied extensions ).... (1 Reply)
Discussion started by: novice82
1 Replies

6. Shell Programming and Scripting

Unix shell script to query linux top consuming processes

Hi All, O/S: Linux 86x64 Red Hat I have a sql script that queries top consuming processes of Linux using TOP commnd. Now I need to automate this task and pass the top processes i.e., PID to the sql script through unix shell script. Could anyone please let me know how to achieve this. ... (2 Replies)
Discussion started by: a1_win
2 Replies

7. Shell Programming and Scripting

Help with shell script - not finding files

Hello, I have a shell script like the one below but cannot get it working: #!/bin/bash #$ -cwd CHR=$2 # directories ROOT_DIR=./ RESULTS_DIR=${ROOT_DIR}results/ # executable SHAPEIT_EXEC=${ROOT_DIR}shapeit.v2.r727.linux.x64/shapeit.v2.r727.linux.x64 # parameters THREAT=5... (1 Reply)
Discussion started by: wmelroy
1 Replies
DH_COMPRESS(1)							     Debhelper							    DH_COMPRESS(1)

NAME
dh_compress - compress files and fix symlinks in package build directories SYNOPSIS
dh_compress [debhelperoptions] [-Xitem] [-A] [file...] DESCRIPTION
dh_compress is a debhelper program that is responsible for compressing the files in package build directories, and makes sure that any symlinks that pointed to the files before they were compressed are updated to point to the new files. By default, dh_compress compresses files that Debian policy mandates should be compressed, namely all files in usr/share/info, usr/share/man, files in usr/share/doc that are larger than 4k in size, (except the copyright file, .html and other web files, image files, and files that appear to be already compressed based on their extensions), and all changelog files. Plus PCF fonts underneath usr/share/fonts/X11/ FILES
debian/package.compress These files are deprecated. If this file exists, the default files are not compressed. Instead, the file is ran as a shell script, and all filenames that the shell script outputs will be compressed. The shell script will be run from inside the package build directory. Note though that using -X is a much better idea in general; you should only use a debian/package.compress file if you really need to. OPTIONS
-Xitem, --exclude=item Exclude files that contain item anywhere in their filename from being compressed. For example, -X.tiff will exclude TIFF files from compression. You may use this option multiple times to build up a list of things to exclude. -A, --all Compress all files specified by command line parameters in ALL packages acted on. file ... Add these files to the list of files to compress. CONFORMS TO
Debian policy, version 3.0 SEE ALSO
debhelper(7) This program is a part of debhelper. AUTHOR
Joey Hess <joeyh@debian.org> 8.9.0ubuntu2.1 2012-06-12 DH_COMPRESS(1)
All times are GMT -4. The time now is 03:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy