for: command not found

I have installed Solaris recently. I was doing "for file in *.c; ...." at the command prompt, it says for: command not found. I tried changing shells, but still wouldn't work.

Any ideas?

Show exactly what you typed and exactly what you got back, word for word, letter for letter, keystroke for keystroke. copy/paste or screenshot if you can. I suspect there's a typo or some missing whitespace in there.

Or... do you happen to have IFS set to a funny value?

% for i in *.c; do mv $i $i.cpp; done;

for: command not found
i: undefined variable

You may be stuck in the C shell, which doesn't have for.

What shells did you try changing to, and in what way did they "not work"?

every time I echo $SHELL, I get /usr/bin/tcsh. How do I get out of this, I just put in at console, csh, bash...I am not sure if it actually does change the shell.

running (t)csh won't get you out of (t)csh :wink:

If you run bash and it does not say 'command not found', you're in bash. It doesn't change SHELL unless you used the shell to login.

If you can't find bash, try ksh, zsh, or sh.

Great! In bash works fine. I do have another question, if I have a shell, i.e. hello.csh, I can run it using ./hello.csh, But what do I need to do to run by doing just "hello" or "hello.csh" without the "./". I have seen this done before.

Thanks

Just running anything that happens to be in the same directory as you without being asked is a big security hazard. That's why it doesn't do it.

PATH is not supposed to contain relative directories, either. So even if you do add . to your PATH, it's not guaranteed to do what you expect.

What I do for my own machine is add ~/sbin/ to my path, and drop my own scripts into ~/sbin/.