simple c-shell question
Two questions really, and they both probably have simple solutions, but I can't seem to find one anywhere. I'm trying to write a simple c-shell script, and here what I need:
1) Is there a way to search a variable for a string of characters and return a simple true/false depending on whether or not the string was found. So I have set var = "randomtext" and I want to search 'var' for the string "random", and have the system return something to indicate whether it was found or not. How can I do this? 2) I want to be able to search for empty variables using an if statement...can this be done? If I do this: set var = if ($var == "") echo "true" This works fine. If there is something actually assigned to 'var', then the system just returns if: Expression Syntax So how can I get such an if statement to work whether or not 'var' is blank? -Matt |
I'll combine answers for both in one example:
Code:
#!/bin/csh |
All times are GMT -5. The time now is 04:38 PM. |