A for loop in an if statement tcsh
I have a program that runs the following commmands
if (-e ${CALIBPLOTS}/y*.eps) then foreach file ($CALIBPLOTS/y*.eps) set jpgfile = `echo $file | sed s/\.eps//g` convert $file ${jpgfile}.jpg end endif The problem I have is taht with that foreach loop, if no files exist the program outputs that no file exists and stops running. So I wanted to put that if statement there so taht it only runs if there is a file. But for some reason if there isn't a file it still runs the foreach loop and stops running. Everything works fine if there is a file there. Any ideas how I can get this to run properly |
Here is a reference.
And why do people use tcsh and not bash? I find much more help with bash. for example, in bash the name substitution will be shorter and more effective: Quote:
Isn't it cool? Sorry that I can't help about tcsh:(. So "${CALIBPLOTS}/y*.eps" is expanded as any "y*.eps" file in the "$CALIBPLOTS" directory, right? In that case, it seems, in the expression "foreach file" it must be present in the same form in order to prevent the "/.eps" part from being added to the variable name? Quote:
|
Well I am using tcsh because I am editing a program that was originally written in tcsh hah. But I added {} to the variable name and it still doesn't work. I get an error telling me that there is no y*.eps.
|
All times are GMT -5. The time now is 09:17 AM. |