Modifying from borne shell to C shell


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Modifying from borne shell to C shell
# 1  
Old 04-25-2001
Data

Just want to know a few conversion tricks.

in Borne Shell, I have the line:

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?

Thanks.
# 2  
Old 04-26-2001
use:
if (-e testmap) then

.........

endif

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


HTH
# 3  
Old 04-26-2001
Bug

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.

=)
# 4  
Old 04-26-2001
-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.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

I am getting strange message when run borne shell script

I have a code: if then#{ process daily files for file in *_${Today}*.csv *_${Today}*.txt do if || then echo "This file will be processed in separate script" continue fi if ;then ... (2 Replies)
Discussion started by: digioleg54
2 Replies

2. Shell Programming and Scripting

Modifying the shell script to select pattern

Hello, I have script which work 70% of the desired task , the output from script.sh is following , however the desired output I require is following . Any piece of suggestion would be great.. thanks in advance, emily #!/bin/bash ... (8 Replies)
Discussion started by: emily
8 Replies

3. Shell Programming and Scripting

Modifying contents of the file in shell script

Hello all, I have a Kconfig file that looks like something below ... ================================ menu "Application type" config GUI_TYPE_STANDARD bool "Standard Application" source "cfg/config/std.in" source... (12 Replies)
Discussion started by: anand.shah
12 Replies

4. UNIX for Dummies Questions & Answers

Modifying a shell script without using an editor

Hi all, I really wan't to know that how to edit a shell script with out using an editor.. Is there any command? (4 Replies)
Discussion started by: buddhi
4 Replies

5. UNIX for Dummies Questions & Answers

borne shell script

I need anwser to this qestion! I havewirte a script that provides line numbered contents of a file which must make use of the following control structures files Command line arguments I am a complete new commer to unix and bourne shell scripting can any one help (1 Reply)
Discussion started by: migg-21
1 Replies

6. Shell Programming and Scripting

Documenattion on Borne And C shell programming

Hi experts, I am new bee in unix programming. How to differenciate a Borne and C shell programming. Can i write a C shell syntax in Borne again shell. Please send me the good links on Borne and Cshell programming . Any help in this regard will be highly appreciated. Regards, Azaz. (3 Replies)
Discussion started by: azazalis
3 Replies

7. Shell Programming and Scripting

UNIX Find command in Borne Shell

I need to perform two separate commands as part of the -exec section of a find command. Is this possible? (1 Reply)
Discussion started by: marshaferry
1 Replies

8. Shell Programming and Scripting

modifying my shell

Hello, I have installed a new program called chimera under the directory /usr/local/bin/chimera. the executable is under the directory /usr/local/bin/chimera/bin/chimera.e If i put myself under the latest directiry and I type ./chimera, the program works. I would like to avoid this and I... (1 Reply)
Discussion started by: nico-hellas
1 Replies

9. UNIX for Dummies Questions & Answers

Need Help With My First Borne Shell Program

I'm working on writing my very first borne shell program and I need some help. I think I'm pretty close to having this correct but I may be off. I think my actual program is coded correctly but the commands I use within it I think are what's throwing it off? **Purpose of the program: To... (3 Replies)
Discussion started by: FuzzyNips
3 Replies

10. Shell Programming and Scripting

Can there be multi-dimensional variable arrays in borne shell?

Hello - I've serached the web but can't find much on array script variables (except that C-shell variables are arrays!) I'm trying to form a 2-D string array: (this is what I want, but in java) String list = { {"one", "two"}, {"three"} }; I know this is a 1-D string array shell... (4 Replies)
Discussion started by: jparker
4 Replies
Login or Register to Ask a Question