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
filesize infyanurag Shell Programming and Scripting 3 05-15-2008 05:00 AM
UNIX and filesize ndoggy020 UNIX for Dummies Questions & Answers 3 12-06-2007 04:14 PM
How to truncate as filesize? Lestat Shell Programming and Scripting 1 06-07-2005 03:24 PM
Sorting ls by filesize peter.herlihy UNIX for Dummies Questions & Answers 2 06-04-2002 08:40 PM
filesize jmg5 Shell Programming and Scripting 2 02-13-2002 07:51 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 05-25-2002
Cameron's Avatar
Cameron Cameron is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2001
Location: Brisbane, Australia
Posts: 499
Question FileSize ???

How do I identify if there is any content in a file?
If there is nothing in a specified file, I'd like to send an email indicating that there is nothing to report.

Any help appreciated.
  #2 (permalink)  
Old 05-25-2002
Jimbo
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Code:
if [ -s myfile ] ; then
   echo 'there is Something in this file'
   echo 'there is some Size to this file'
else
   echo 'file is empty'
fi
  #3 (permalink)  
Old 05-28-2002
LivinFree's Avatar
LivinFree LivinFree is offline Forum Advisor  
Goober Extraordinaire
  
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
You can use the "-f" option too, to make sure that a file exists in the first place.
The "-s" option checks for a non-zero size file.

See if your unix has a man page for "test".
  #4 (permalink)  
Old 05-28-2002
Cameron's Avatar
Cameron Cameron is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2001
Location: Brisbane, Australia
Posts: 499
Thanks guys.

I ended uo doing a set `file $myfile` and grabbing $2.

Learning something new everyday
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 01:57 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