if test -s testmap
then
...
fi
## testmap is a filename and I wanna test whether it exists
## then do whatever
How can I convert that to C Shell?
I've tried:
if (test -s testmap) then
...
endif
but it doesn't work. Says if: invalid expression.
Also, in Borne Shell, if I run a program called 'agent' in the background by typing in:
agent &
And it's process ID is stored in the variable $! and I can actually print it in Borne Shell.
But it seems that $! doesn't exists at all in C Shell. How can I do the similar thing in C Shell?
What you're doing is just testing if the file exists or not. What I want to test, is that the file exists and has file size larger than 0, which is done by using the switch -s in borne shell.
-z tests whether the file is zero size. So you can do ! -z to test for greater than 0. This is in the csh man page.
BTW, I would strongly consider avoiding csh for shell programming tasks as it is fairly inadequate in several areas. See: <A HREF="http://www.perl.com/pub/language/versus/csh.html">Csh Programming Considered Harmful</A> by Tom Christiansen.