|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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.
|
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
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 01:36 AM.. |
| Sponsored Links | ||
|
|
#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
|
||||
|
||||
|
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 |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
Quote:
Code:
ls -l * or ... Code:
while read afile
do
ls -l $afile
done < listfile |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
ls -l | awk -F" " '{ print $5,$9 }'
|
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
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/$LOGAdd 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! |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| check the file size | sandy1028 | Shell Programming and Scripting | 1 | 11-11-2010 06:16 AM |
| Check the file size - help | sithara | Shell Programming and Scripting | 5 | 06-10-2010 10:52 AM |
| Check for file size is zero or not. | Hangman2 | Shell Programming and Scripting | 3 | 04-14-2009 04:08 PM |
| How to check the file size in a dir | bsathishmca | Shell Programming and Scripting | 6 | 10-02-2008 10:26 AM |
| To check file size | Shahul | Shell Programming and Scripting | 2 | 09-15-2008 11:53 AM |
|
|