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



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Checking for a file in file pattern before deleting it dsrookie UNIX for Dummies Questions & Answers 1 05-09-2008 05:29 PM
Error checking a file from previous file size stuck1 Shell Programming and Scripting 2 12-06-2007 08:39 AM
checking size of the first line in a log file kiran1112 Shell Programming and Scripting 19 03-22-2007 02:46 PM
Help with checking file size ssmith001 Shell Programming and Scripting 15 09-08-2005 10:48 PM
Checking file size jkuchar747 UNIX for Dummies Questions & Answers 2 03-02-2005 02:34 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 10-10-2007
skwyer skwyer is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 8
Unhappy Checking file size of zip file

I'm having a problem with a bash shell

The shell is running through a list of zip filenames, copying the zip files to another location and adding a file to the zip files.

All this is working great, however I also need to report on the size of the zip file and I keep getting wrong answers.

Here's how I currently have it set up

Code:
cat $INPUT_FIL |
while read ITEM
do
   #copy zip file to new location, add file
   ZIP_SIZE=`ls -sh $ZIP_FIL`
   echo $ZIP_SIZE
done
I get numbers that are way off the mark when I run it this way. I've moved the ZIP_SIZE to various points throughout the do loop and I get a different answer in different places. All of them are wrong.

I've also tried using wait $!

How can I get an accurate size count?
  #2 (permalink)  
Old 10-10-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,759
I'm assuming you're on Linux:
First off, ls -l gives the file size in bytes, ls -lh makes it human readable.

Plus, I don't see where you are copying things.

-s gives a size in blocks. If you copy from one filesystem to another, filesystem #1 may have a blocksize of 512, the other filesystem #2 may have a blocksize of 1024, so -s would give you differing results. Don't use -s
  #3 (permalink)  
Old 10-11-2007
skwyer skwyer is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 8
ls -lh worked wonderfully, thanks.

I didn't show the code for copying and stuff because that was working.

Thanks again!

Mike
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 10:37 PM.


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