Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google site



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-21-2009
Registered User
 

Join Date: Nov 2009
Posts: 7
Checking the file for non-zero byte

Hi,

An 'If' clause has to be executed if file1.txt has any contents in it.

Suggest us...
Sponsored Links
  #2 (permalink)  
Old 11-21-2009
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 6,169

Code:
if [[ -s file1.txt ]] ; then
  # do stuff to the file here
fi

  #3 (permalink)  
Old 11-21-2009
thegeek thegeek is offline Forum Advisor  
Registered User
 

Join Date: Apr 2009
Location: /usr/bin/vim
Posts: 657
for perl:


Code:
print "file ->sample.txt<- is of size non zero" if ( -s "./sample.txt" );

Refer: File Test Operators
Sponsored Links
Reply

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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Remove a byte(Last byte from the last line) vinayrao Shell Programming and Scripting 1 02-04-2009 05:18 PM
ftp 0 byte file jjmill1979 UNIX for Dummies Questions & Answers 1 09-05-2008 12:52 PM
Check if 2 files are identical byte-to-byte? krishmaths Shell Programming and Scripting 4 09-04-2008 02:37 AM
zero byte file dsdev_123 AIX 2 03-20-2008 10:50 AM
0 byte file with no name???? miltonkeynesguy Shell Programming and Scripting 5 08-17-2007 09:01 AM



All times are GMT -4. The time now is 03:41 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-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0