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
Checking Multiple file existence lathish Shell Programming and Scripting 1 06-16-2008 01:02 PM
Checking for existence of a flat file in UNIX ! Ariean Shell Programming and Scripting 4 04-25-2008 02:58 PM
Checking the existence of a file.. igandu Shell Programming and Scripting 7 06-13-2007 03:47 AM
checking file existence DILEEP410 Shell Programming and Scripting 3 01-24-2007 12:43 PM
how to test for file existence using file size? forevercalz Shell Programming and Scripting 3 10-26-2005 10:02 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-27-2008
lathish lathish is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 8
Multiple file existence and checking file size

I want to check the files in particular directory are more that 0 Bytes i.e, Non zero byte file. The script should print a msg if all the files in that directory are empty( 0 Byte).
  #2 (permalink)  
Old 06-27-2008
vbe's Avatar
vbe vbe is online now Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,569
For the message:
if ls -l|wc -l returns 1 then directory is empty...
if [ ls -l |wc -l returns a greater value ] AND if [ ls -l|grep tot returns 0 ]
then the directory contains only 0 bytes files
Just thoughts...
Many solutions exist this is just using ls...
  #3 (permalink)  
Old 06-29-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,420
Code:
ls -l . | awk '$5>0{n++}END{if(n==0) print "All the files in that directory are empty( 0 Byte)."}'
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 05:11 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