The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Block Size Ruben78 AIX 3 04-28-2008 08:40 PM
block size bache_gowda UNIX for Dummies Questions & Answers 1 05-31-2007 07:21 AM
How to know the OS Block size Dilippatel UNIX for Dummies Questions & Answers 1 07-20-2004 07:23 AM
block size csaunders SUN Solaris 3 05-19-2004 02:35 PM
os block size kburrows Filesystems, Disks and Memory 1 10-10-2002 04:45 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-11-2005
moxxx68's Avatar
moxxx68 moxxx68 is offline
Registered User
  
 

Join Date: Mar 2004
Posts: 301
block size and du output

i wrote this code to figure if two identical directories on different devices one on a partition and one on a loop had the same total size for -size +0 file only in recrusive tree form.:
awk '$1 ~ /^-/{total=i;i<=NR;i+=$5;print $0}END{print total}'
file1.... .
the output of du -hb was slightly different, but the total of files was the same.. so I tried to figure out the total of the bytes in blocks (?).. (correct me if I am wrong!).
i used bc and took the size of the number of blocks the file added up to which was 21 and multiplied it by (512*512) and devided by 2 what is this output? it looks similiar to the number I got through du but with a couple of digits on the end! is this the size in byts? two byt words? or am i supposed to devide by 8..
{quite confused) moxxx68...
  #2 (permalink)  
Old 01-11-2005
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Hmm... this confusion is contagious - i'm not too sure I follow you at all!

I assume from your previous posts you're still using Linux (and therefore GNU ls). I also will assume that you're trying to display file sizes in 512 byte blocks? If so, you don't need to do any calculation - if you run

ls -Rls --block-size=512

you'll get a total block count at the top of each directories' listing - with each files size in 512-byte blocks in the first column of output, e.g.

Code:
$ ls -Rls --block-size=512
.:
total 16
  12 -rw-r--r--    1 zb foogroup     5265 Jan  2 22:34 index.html
   4 -rw-r--r--    1 zb foogroup     2043 Jan 10 14:52 submit_contact.php
So, armed with this, it's fairly easy to grep out the "total"s, and if desired, gain a total block count for the entire tree....

Code:
ls -Rls --block-size=512 | grep "^total" | awk 'BEGIN{c=0} {c+=$2} END{print c}'
Cheers
ZB
  #3 (permalink)  
Old 01-11-2005
moxxx68's Avatar
moxxx68 moxxx68 is offline
Registered User
  
 

Join Date: Mar 2004
Posts: 301
cheers!
thanx for clueing me in..
moxxx68
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:26 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0