stat


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users stat
# 1  
Old 09-07-2008
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 20:01:42.000000000 +0530
Change: 2008-09-08 20:01:42.000000000 +0530


wat is the significance of BLOCKS and IO BLOCK here?
# 2  
Old 09-07-2008
BLOCKS tells you that, when measured in standard 512 byte blocks, 8 blocks have been allocated for this file. IO BLOCK 4096 tells you that i/o to the file will happen in 4096 byte blocks at a time. Putting it all together... the filesystem allocates 4096 byte blocks at a time to a file. Your file is using 1 such block.
# 3  
Old 09-07-2008
stat

Quote:
Originally Posted by Perderabo
BLOCKS tells you that, when measured in standard 512 byte blocks, 8 blocks have been allocated for this file. IO BLOCK 4096 tells you that i/o to the file will happen in 4096 byte blocks at a time. Putting it all together... the filesystem allocates 4096 byte blocks at a time to a file. Your file is using 1 such block.
it means that if i increase in data of file,then it would occupy 16 blocks on disk
even if size of file is less than 16 block but greater than 8 blocks?
and why do we need block for allocation?
# 4  
Old 09-08-2008
Once you fully use the first 4096 block, yes you will get a 2nd. The filesystem works in blocks for efficiency. Metadata is needed to remember which block is assigned to which file. If the block size was 1 byte, more than half of the filesystem would be needed for meta-data. Also writing one byte at a time would take too long. So it reads and writes data in large blocks and buffers it to reduce the amount of physical I/O.
# 5  
Old 09-08-2008
Quote:
Originally Posted by Perderabo
Once you fully use the first 4096 block, yes you will get a 2nd. The filesystem works in blocks for efficiency. Metadata is needed to remember which block is assigned to which file. If the block size was 1 byte, more than half of the filesystem would be needed for meta-data. Also writing one byte at a time would take too long. So it reads and writes data in large blocks and buffers it to reduce the amount of physical I/O.
thanx for this information......
but i would like to know one more thing that why do we need 2 kind of blocks
one block of size 512 bytes & another if I/o BLOCK of 4096 bytes.
wat is the use of first kind of block?
# 6  
Old 09-08-2008
The 512 is only to report the size in a standard format. When you see that a file is using 8 blocks, that means the same thing on all versions of unix. 512 was chosen because some old versions of unix really used a blocksize of 512.
# 7  
Old 09-08-2008
thanx for all this information.........
Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

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. UNIX for Dummies Questions & Answers

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 ~#stat /etc/passwd File: `/etc/passwd' Size: 999 Blocks: 8 IO... (4 Replies)
Discussion started by: mhs
4 Replies

5. Shell Programming and Scripting

using File::stat

Hello everyone, I need some help on a perl script. The script is to open a dir and print out the date of last modification on all files. I'm been trying this code but it doesn't work. use File::stat; open (D,"$ARGV") or die "Can't open\n"; while (defined ($file = readdir D)) { next... (3 Replies)
Discussion started by: new bie
3 Replies

6. Shell Programming and Scripting

stat command with ls -l

If i do ls -l i get the result rwx-rw-r ...... ............... file. How can i get the result in octal format. All other output will be the same as ls -l shows. The rwx-rw-r would be like 755 etc. (7 Replies)
Discussion started by: cola
7 Replies

7. 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

8. 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

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. Programming

stat() fails!!! what can i do?

Hi all, I can not understand why my stat() function fails all the time when function tries to go recursevly. Someone suggested that it might be poiter problem. Please, look up my code at: www.donnelly.cc.ks.us/readdir_test.c. How can i solve this problem? Any suggestion are welcome! Thank you... (3 Replies)
Discussion started by: solvman
3 Replies
Login or Register to Ask a Question