Re: if: Expression syntax help in C shell
- From: Maxwell Lol <nospam@xxxxxxxxxxx>
- Date: Thu, 11 Dec 2008 21:50:47 -0500
sorry - I posted too soon
Steve <javacc2@xxxxxxxxx> writes:
I got "if: Expression syntax" error when I executed this simple
script. I have no idea what went wrong. please help. thanks!!
#!/bin/csh
I suggest
#!/bin/csh -f
This protected your script from interacting with the user's ~/.cshrc file
setenv SRCPATH /home/test
if (/usr/bin/ls $SRCPATH | wc -l > 0) then
You should always put spaces after brackets with csh.
And you can't use pipes where csh wants an expression.
And if you want to test for the existance of files in a directory, I'd use
if ( -d "$SRCPATH" ) then
set count = ( `ls "$SRCPATH" | wc -l` )
else
echo directory $SRCPATH missing
exit
endif
if ( $count > 0 ) then
echo great 0
else
echo less 0
endif
.
- References:
- if: Expression syntax help in C shell
- From: Steve
- if: Expression syntax help in C shell
- Prev by Date: Re: how to change a certain line in a file, using SED ?
- Next by Date: Re: Dotted or executed?
- Previous by thread: if: Expression syntax help in C shell
- Next by thread: Re: if: Expression syntax help in C shell
- Index(es):
Relevant Pages
|