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
How to unzip a zip file into a folder with the zip file's name? basis Shell Programming and Scripting 5 06-05-2008 08:10 AM
Change a file's timestamp shibajighosh AIX 6 05-27-2008 02:26 PM
get a file's timestamp shihabvk UNIX for Advanced & Expert Users 1 05-30-2005 07:18 AM
checking file's permissions and change them K-ONE Shell Programming and Scripting 7 04-10-2005 10:09 AM
How to calculate file's size in directory and subdirectory KLL Shell Programming and Scripting 4 10-16-2003 08:02 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-21-2004
ropers's Avatar
ropers ropers is offline
Registered User
  
 

Join Date: Dec 2001
Location: Dublin
Posts: 48
best way to get a file's size?

I'm trying to get a file's size.
Specifically, I want to check whether a file is larger than 650MB.
I've tried:

find . -name "filename" -size +681574400 -print

Oddly, that didn't seem to work.
(NB: 1024 bytes x 1024 x 650 = 681574400 bytes = 650 MB)

The problem seems to be the "-size" primary and it's numerical argument "+681574400".

The man pages say:
Quote:
All primaries which take a numeric argument allow the number to be pre-
ceded by a plus sign (``+'') or a minus sign (``-''). A preceding plus
sign means ``more than n'', a preceding minus sign means ``less than n''
and neither means ``exactly n''.
So I don't understand why it doesn't work.
I have since found that the problem can also be solved by getting the file size with ls -l and awk, but I think that's to AWKward (horrible pun .

Seriously, I've got these questions:

- Why does the above not work and what needs to be done for it to work?

- What do people think is the best and safest way of doing such a file size check in a script?

NB: the shabang is #!/bin/sh -- I could obviously change that to anther shell/language, but I want to remain as compatible as possible.

Many thanks in advance!
 

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:42 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