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
Polling continously for presence of a file manoj39 Shell Programming and Scripting 4 06-23-2009 01:59 PM
check the input Shilpi UNIX for Dummies Questions & Answers 1 03-04-2008 08:26 AM
How do I test for the presence of a file in Bourne Shell vins UNIX for Dummies Questions & Answers 3 03-17-2006 03:42 PM
Check on Input dhananjaysk Shell Programming and Scripting 3 03-13-2006 01:55 PM
What can i do to check that the input is all alphabet.. ? XXXXXXXXXX Shell Programming and Scripting 4 02-19-2002 07:09 PM

Reply
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 10-01-2009
newpromo newpromo is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 7
check presence of input file

My script is taking a file "input.in" as input for running the script. My worry is that i need to execute the script only if the file is present, if it's not don't perform the next commands.

Just to have a check at the beginning of the script : If "input.in" exists, then go on. If it's does not exist exit.
  #2 (permalink)  
Old 10-01-2009
rdcwayx rdcwayx is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 223
Code:
if [ -f input.in ] ; then

  DO THE JOB

else

  exit

fi
  #3 (permalink)  
Old 10-01-2009
newpromo newpromo is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 7
Thank you, it's OK !

---------- Post updated 02-10-09 at 12:19 AM ---------- Previous update was 01-10-09 at 07:29 AM ----------

Hello again,

Now i need to test if the input file "input.in" exists and if it's NOT empty, then execute next commands. Else exit

Thanks in advance,
  #4 (permalink)  
Old 10-01-2009
scottn scottn is online now Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 1,051
Hi

Code:
[ -s file ]
Read the man page for your shell. It tells you all you need to know.
  #5 (permalink)  
Old 10-01-2009
newpromo newpromo is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 7
Thank you !
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 On




All times are GMT -4. The time now is 07:04 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