The UNIX and Linux Forums  

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
command to find out total size of a specific file size (spread over the server) abhinov SUN Solaris 3 08-08-2007 07:48 AM
Find lines greater than 80 characters in a file mrgubbala Shell Programming and Scripting 8 03-11-2007 12:51 AM
Find in file. Does this exist under UNIX? scampsd UNIX for Dummies Questions & Answers 2 01-19-2006 11:24 AM
File size greater than 0 skammer1234 Shell Programming and Scripting 1 08-03-2002 11:30 AM
file exists and size greater that zero methos Shell Programming and Scripting 3 03-25-2002 01:44 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 11-23-2005
guhas guhas is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 22
Unhappy Can I find wether a particular file exist and size greater than zero...help please

Can I find wether a particular file exist and size greater than zero in one line command.

similar to this

if [-f *.log] && [ -s *.log]

something in one if test .... e.g. if [-f -s ????]

1.) is it possible ? ... if yes how

2.) what would be the return type in case there is success or failure. I mean if both are true or any one is true
  #2 (permalink)  
Old 11-23-2005
Abhishek Ghose Abhishek Ghose is offline
Registered User
  
 

Join Date: Sep 2005
Location: Chennai
Posts: 81
You might find this helpful: can't TEST multiple arguments for a file
  #3 (permalink)  
Old 11-23-2005
dangral dangral is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2002
Posts: 699
According to Oreilly's "UNIX in a Nutshell,":

Quote:
-s file
file exists and has a size greater than zero.
So all you need is the -s.
  #4 (permalink)  
Old 11-28-2005
guhas guhas is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 22
can i find the size of the file ! ....

Quote:
Originally Posted by Abhishek Ghose
You might find this helpful: can't TEST multiple arguments for a file
***********************
hi ...

what i mean is here below
I have a folder which have files + sub folders (which in turn contain files). The files in foder or sub folder might be empty or size greater than zero. now if I use TEST then it is only going to find the files in the curent folder. but it will not give me the information about the files inside the sub folder.

now how can i get the information of both the files present inside folder or subfolder wether they are greater than zero or not ( empty or not)

Thanks for ur co-operation .. looking forward for the reply

****************************************
  #5 (permalink)  
Old 11-28-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
find . -type f ! -size 0 -exec ls -l {} \;
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 06:04 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