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
script(1)							   User Commands							 script(1)

NAME
script - make record of a terminal session SYNOPSIS
script [-a] [filename] DESCRIPTION
The script utility makes a record of everything printed on your screen. The record is written to filename. If no file name is given, the record is saved in the file typescript. See WARNINGS. The script command forks and creates a sub-shell, according to the value of $SHELL, and records the text from this session. The script ends when the forked shell exits or when Control-d is typed. OPTIONS
The following option is supported: -a Appends the session record to filename, rather than overwriting it. NOTES
script places everything that appears on the screen in filename, including prompts. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ SEE ALSO
attributes(5) WARNINGS
script can pose a security risk when used in directories that are writable by other users (for example, /tmp), especially when run by a privileged user, that is, root. Be sure that typescript is not a link before running script. SunOS 5.11 30 Jan 2004 script(1)
All times are GMT -4. The time now is 10:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy