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
what is the right syntax ?? convenientstore Shell Programming and Scripting 7 06-04-2007 01:21 AM
vim and syntax max os kezzol OS X (Apple) 1 04-30-2007 11:22 AM
Help with the syntax chandhar Shell Programming and Scripting 2 03-26-2007 04:38 AM
Help with the syntax chandhar Shell Programming and Scripting 2 03-25-2007 10:48 PM
What does this syntax mean... DrAwesomePhD UNIX for Dummies Questions & Answers 1 07-31-2006 08:54 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-02-2005
Registered User
 

Join Date: Sep 2005
Posts: 130
Unhappy if-else syntax in csh

Dear friends,

I am writing a script usiing c-shell.

iwant if -else syntax in c-shell
i have taken twovariables and in one variable iam storing sysdate.and comparing with other variable

if both are same then iam renaming file as oct_2005.

please see below code

set mon=`date +%m`
set yer=`date +%Y`
set dat=`date +%d`


set pass=`cal $mon $yer | sed '/^$/d' | tail -1 | awk '{printf $NF}'`
echo $pass
set vrfir=`expr $pass - 1`
echo $vrfir
echo $dat
echo $pass

if test $dat == $vrfir ; then
mv schedule $montmp$yer
#else
#mv schedule $montmp$yer
fi




regards
rajan
Reply With Quote
Forum Sponsor
  #2  
Old 11-02-2005
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,328
I am not a csh programmer, in fact this will probably turn you away from it as well.

Anyway, the syntax for 'if' in csh is like this:
Code:
if ($dat == $vrfir) then
   echo foo!
else
   echo bar!
endif

Last edited by blowtorch; 11-02-2005 at 04:16 AM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:57 AM.


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

Content Relevant URLs by vBSEO 3.2.0