if-else syntax in csh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting if-else syntax in csh
# 1  
Old 11-02-2005
Data 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
# 2  
Old 11-02-2005
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 07:16 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Nice syntax in csh on Solaris 10

Dear Solaris Experts, I would like to set the lowest priority when running a resource intensive program in C shell on Solaris 10 similar to the following syntax that works in Korn shell: $ nice -n 19 programHowever, I got the following error when running the same command in C shell: 9 ... (3 Replies)
Discussion started by: gjackson123
3 Replies

2. Shell Programming and Scripting

What does this do in CSH?

CSH experts What does the following do in CSH? :(){:|:&};: I was asked the question, but I don't know. I'm not aware of the context. Any ideas? Thanks! (1 Reply)
Discussion started by: wallg
1 Replies

3. Shell Programming and Scripting

.sh to .csh

Hi All, Could any one of you give me a hand to convert the following line of codes from .sh to .csh please ? proc_id=`fuser /tmp/test` if then echo "File is not being used by any thing" fi if then echo "File is being used... please wait" sleep 1 fi Regards. (1 Reply)
Discussion started by: sraj142
1 Replies

4. Shell Programming and Scripting

syntax error in .csh file

Hi all, I am trying to modify a script for research purposes and am having difficulty here as I have little prior experience with C-shell scripting. The script looks as follows (it includes tcl commands like runFEP that you can ignore) #!/bin/bash for ((old=1, new=2; old<=4; ... (5 Replies)
Discussion started by: chrisjorg
5 Replies

5. Shell Programming and Scripting

Using \n in csh

I am trying to use \n for a new line in csh like this echo "some text\n" echo "some more text\n" but am getting some text\n some more text\n (10 Replies)
Discussion started by: kristinu
10 Replies

6. Shell Programming and Scripting

if in csh

I am using this code echo "opt_tpath = $opt_tpath" if ($opt_tpath == 1) echo " -tpath = $Atpath\n" and is giving opt_tpath = 0 Atpath: Undefined variable. Atpath should only be printed in opt_tpath == 1 but it still tries to print. ---------- Post updated at 10:05 AM ----------... (1 Reply)
Discussion started by: kristinu
1 Replies

7. UNIX for Dummies Questions & Answers

csh

what is a .csh extension? there is a command line: mkaphed_ctio.csh Does anyone know what this is? :confused::confused::confused: (1 Reply)
Discussion started by: cosmologist
1 Replies

8. Shell Programming and Scripting

csh failing to call an 2 embedded csh script

I have an extraordinary problem with a csh script.....(feel free to berate the use of this but I'm modifying an existing bunch of them) Anyway, I have a master csh script which in turn calls a second csh script. This second csh script is below. Within this second script are two compiled C++... (1 Reply)
Discussion started by: pollsizer
1 Replies

9. Shell Programming and Scripting

Need a better find for csh

At /home/me/bin I've got a script called fg. The meat of it is: find . -name "$1" | xargs grep $2 The intent is to call it as "fg file_pattern search_pattern" and search all matching files. I've added the directory to my path and made the file executable, but when I try to use it I get ... (3 Replies)
Discussion started by: James McMurray
3 Replies

10. UNIX for Dummies Questions & Answers

csh syntax

I am trying to list output in columns in csh. What would be the syntax for this shell if in ksh it is: ls -d !(*SNMP*) ? (0 Replies)
Discussion started by: charlie11k
0 Replies
Login or Register to Ask a Question