Modifying from borne shell to C shell

Just want to know a few conversion tricks.

in Borne Shell, I have the line:

if test -s testmap
## 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
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?


if (-e testmap) then



BTW. "if test -f file" is more suitable to check File existance in Bash. (-f: is File exist or normal file and not a directory.)

I think tcsh supports $!. or use jobs -l


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.

How can I do that in Csh?

Thanks for your help though.


-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="">Csh Programming Considered Harmful</A> by Tom Christiansen.