stat output


 
Thread Tools Search this Thread
# 1  
stat output

hi guys

i got confused about stat output

stat manual says

File : Size in Bytes
Blocks : Number of blocks used
IO Block : Size in bytes of every block.

when i use stat command for passwd file it says
Code:
~#stat /etc/passwd   File: `/etc/passwd' Size: 999       	Blocks: 8          IO Block: 4096   regular file Device: ca00h/51712d	Inode: 845         Links: 1 Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root) Access: 2011-05-26 12:14:41.000000000 +0200 Modify: 2011-05-26 12:14:41.000000000 +0200 Change: 2011-05-26 12:14:41.000000000 +0200

size is 999 bytes and every block is 4096 bytes how can this file use 8 blocks ???

8 blocks === 8 * 4096 = 32768

file size should be 32769 bytes to use 8 blocks !!
# 2  
Files can have smaller sizes than their block usage. You can have a file that's 1 byte in size, even though it'd use at least one block. The extra space is simply reserve for it.

It's been given more than one block in case someone needs to extend the file later. Less fragmentation that way.

The file might also have been larger in the past.
# 3  
thx man but i think it's not rational !!

a file with 999 in bytes which can store in only 1 block use 8 blocks ???

1 block for store and 7 blocks reserve for it ????
# 4  
For frequently-modified files, it's rational. I have a set of text files that gets appended to frequently, and if they had more blocks reserved for them at a time, they'd fragment less than they do. If I found a straightforward way to change that without reformatting the FS I would.

Also, like said, it may have been larger in the past, and the extra blocks got kept in case the file becomes large again.

The other thing is, it may not be going by the I/O block here.
# 5  
Does your stat allow for the --printf option? If yes: %B The size in bytes of each block reported by %b
Issue
Code:
stat --printf=%B /etc/passwd
512

- this will output the disk block size. 8 * 512 = 4096, the usual disk block allocation size.
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Science: Mathematics
Difficulty: Medium
111,111,111 x 111,111,111 = 12,345,678,987,654,321
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help with stat command

Hi Experts, I am here with very simple request: #!bin/bash a=`stat -c %y log1.csv` echo $a and this stat command returning value as 2013-08-11 05:42:10.000000000 -0400: But I want to see in mm/dd/yyyy format? any help is highly appreciated thank you ---------- Post... (9 Replies)
Discussion started by: parpaa
9 Replies

2. Shell Programming and Scripting

Stat value changes

Die to what all operations, the "Modify" and "Change" values of stat output changes for a file. I found, during editing a file, Change and Modify alters. When chmod'ing Change alters, while Modify doesnot alters. Is there more situations where these changes? (1 Reply)
Discussion started by: anil510
1 Replies

3. UNIX for Dummies Questions & Answers

Stat command

i know this command does not exist in solaris. however, i read somewhere on this forum that basically everything the stat command provides in other oses can be obtained in solaris using the ls command. i've searched the forum for a while now and i cant find the thread. does anyone know about... (1 Reply)
Discussion started by: SkySmart
1 Replies

4. Shell Programming and Scripting

Putting echo output as input to stat

I have a string with escape differentiators as a result of searching for a file using find. Essentially find returned to my shell variable several absolute paths each ending with the file name and each path/file separated by \n. Echo recognizes the escape sequence and is able to print the paths... (3 Replies)
Discussion started by: Ebodee
3 Replies

5. Shell Programming and Scripting

cannot stat error

I'm trying to find .tif files in a directory tree and rename them prior to zipping them and moving them to another dir. this is my code: cd $TMPPATH pwd ctr=0 for i in 'find . -name "*.tif"' do let "ctr+=1" newtifname=$DATEDIR"_"$SEQ"_"$ctr".tif" mv "$i"... (6 Replies)
Discussion started by: rss0213
6 Replies

6. Solaris

stat: Available on Solaris?

JoeyG's note in the following thread got me thinking about using stat more often in file operations. I've only ever used it within perl - didn't even realize there was a commandline version of it.... (3 Replies)
Discussion started by: Smiling Dragon
3 Replies

7. Programming

Q with stat()

From reading various articles on the net, I know stat() is used on files to get things like permissions, sizes etc... As a folder is a special type of file in Unix, I assumed that stat() could work on it as well as any general file. However, from running my program, perror() reported that the... (3 Replies)
Discussion started by: JamesGoh
3 Replies

8. UNIX for Advanced & Expert Users

stat

the output of stat command is Size: 238 Blocks: 8 IO Block: 4096 regular file Device: 80ah/2058d Inode: 736783 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 500/ gajju) Gid: ( 500/ gajju) Access: 2008-09-08 20:00:15.000000000 +0530 Modify: 2008-09-08... (6 Replies)
Discussion started by: gajju
6 Replies

9. UNIX for Dummies Questions & Answers

Cannot stat?

Hi! I ran into a problem with a job I'm running. All it is doing is a "touch" on a filename. However, when I ran the job, it error'd out and got the message 'cannot stat'. When I restarted the job (making no changes) it worked just fine. Anyone know what this means? (1 Reply)
Discussion started by: lgardner
1 Replies

10. Shell Programming and Scripting

stat command

how can use "stat command"????.. (2 Replies)
Discussion started by: emreatlier
2 Replies

Featured Tech Videos