The UNIX and Linux Forums  

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
Check file size and remove files srivsn Shell Programming and Scripting 5 05-28-2009 02:09 PM
unix script to check whether particular file exists and to find its size Balachandar Shell Programming and Scripting 9 02-05-2008 03:56 AM
Check backup file size on backup tape ayhanne UNIX for Dummies Questions & Answers 0 10-25-2007 12:41 PM
Perl FTP - check file size rahulrathod Shell Programming and Scripting 1 02-20-2007 10:21 AM
file size check malaymaru Shell Programming and Scripting 2 10-19-2005 01:26 AM

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 06-15-2005
alnita alnita is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 6
Check file size

I need a unix script that will check the size of multiple files in the same directory or from a text file.
  #2 (permalink)  
Old 06-16-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
that will check the size of multiple files

What do you mean by check ?

Here is a script that will tell you the file size in bytes.


Code:
#! /bin/sh

ls > listing.txt

while read file
do
echo "Size of $file`stat -c=%s $file`"
done < listing.txt

Vino

Last edited by vino; 06-16-2005 at 02:36 AM..
  #3 (permalink)  
Old 06-16-2005
poste_d_ordure poste_d_ordure is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 3
I just need the size of one file

I tried manipulating the code and got an error that -c was not a valid option. When I tried the valid options, I got a rather complete list of stats, not just a numeric value for file size
  #4 (permalink)  
Old 06-16-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
How about


Code:
stat --format=%s $file

instead


Code:
stat -c=%s $file

From the man pages of stat,
Code:
-c

and
Code:
--format

are the same.

Dont know what effect it could have. Check it out.

Vino
  #5 (permalink)  
Old 06-16-2005
Just Ice's Avatar
Just Ice Just Ice is offline Forum Advisor  
Lights on, brain off.
  
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 637
Quote:
Originally Posted by alnita
I need a unix script that will check the size of multiple files in the same directory or from a text file.
try ...

Code:
ls -l *

or ...

Code:
while read afile
do
    ls -l $afile
done < listfile

  #6 (permalink)  
Old 06-16-2005
bhargav's Avatar
bhargav bhargav is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2004
Location: USA
Posts: 511
ls -l | awk -F" " '{ print $5,$9 }'
  #7 (permalink)  
Old 06-20-2005
qfwfq qfwfq is offline
Registered User
  
 

Join Date: Feb 2005
Location: Canada
Posts: 133
Here is a script I have done to compile everyday statistics about files on the system. Let's say here, all files bigger than 500Mg.


Code:
REP=/home/user
LOG=filecheck.log
DATE=`date`

date >> $REP/$LOG

find . -size +1000000 -exec ls -l {} \; >>$REP/$LOG

Add it to your crontab and you can have a look everyday to the log file or send the output by mail to yourself.
Hope it helps!
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 08:18 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