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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Is there any Javascript things for Lynx? zeus Security 7 11-10-2007 05:56 PM
Question about several things in C V4D3R High Level Programming 1 09-13-2007 07:56 PM
When things doesn't run into crontab??? nymus7 Shell Programming and Scripting 4 04-24-2006 08:11 AM
Complicating things? bconnor High Level Programming 1 03-30-2006 07:07 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-27-2005
Registered User
 

Join Date: Sep 2005
Posts: 74
Stumble this Post!
how to convert things from csh to sh

i have this method in csh that check for file exist.


#check that file exists
if ( ! -e $6$5 ) then
echo $6$5 Not Found
exit 8
endif

however i wanted in to be in just sh. so i change the code to:
if [ ! -e $6$5 ]; then
echo $6$5 Not Found
exit 8
fi

I get error showing test arguments needed or something like this..is there any problem with my coding? Btw the parameters are passed in...$5 is a text file and $6 is a path name.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-28-2005
Registered User
 

Join Date: Jul 2005
Location: England
Posts: 183
Stumble this Post!
Put quote around the variable argument in the if staement. eg

if [ ! -e "$6$5" ]

The reason you get an error in your own code when $5 and $6 are both empty is that the '-e' test requires an argument. By putting quotes round it you force an argument of a null string (rather than no argument at all) when $5 and $6 are both empty.

Last edited by Unbeliever; 10-28-2005 at 07:06 AM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:41 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0