Advertisement

UNIX Shell Programming

Started by June 24, 2003 07:11 AM
7 comments, last by johnc82 21 years, 4 months ago
hi.... Anyone knwo where can i find some information for UNIX shell programming.........??? Thanks
:-)
Specificity makes helping much easier. Which shell? What about the shell? Where have you looked? What''s your skill/knowledge level?
Advertisement
o''reilly publishes some good books
well....

I''m using the Cygwin.......
I''m not very sure what shell it using.....


:-)
I think the default install sets up BASH. You may also have installed CSH or TCSH.

BASH is probably the most popular shell for Linux, CSH is the BSD default, TCSH is the OS X default.

There are a lot of similarities between shells, but enough differences where you should pick one and use it. Personally, I don''t find there to anything that you can do in one that you can''t do in another that creates a scenario where you say, "I can''t live without that feature." But maybe you''ll be different. =)

I''d start with BASH.

http://www.tldp.org/LDP/abs/html/index.html

Its for advanced, but if you know some programming you''ll be fine. You can find other ones on the web, a google search for BASH tutorial will give you plenty of returns.

Interim

Hmm,

Here''s a few places to start:

user@machine: $ man ${SHELL##*/}

http://www.google.com/



.zfod
Advertisement


Assuming bash, of course.


.zfod
Cygwin runs bash by default, so

$ man bash
$ info bash

And the GNU online documentation should all prove good starting points.



[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
quote: Original post by Interim
I think the default install sets up BASH. You may also have installed CSH or TCSH.

BASH is probably the most popular shell for Linux, CSH is the BSD default, TCSH is the OS X default.
Never do shell scripting in the CSH (C shell, has nothing to do with the C programming language BTW). The CSH can bring you massive headaches if you try to do shell scripting in it. I don''t think it was really meant to be a shell to do scripting in, but more for the user to use and benefit from.

If you''re doing shell scripting, I think there are two or three main shells people use to script in. The first is SH (the Bourne Shell, the original shell). The Bourne Shell (sh) has basically no features a user might want, which means that it is FAST, which is what you want when shell scripting. BASH is the Bourne Again Shell. It is basically 100% compatible with the Bourne shell, so doing shell scripting in either of these is basically the same.

The last one is the Korn Shell (ksh), and it has a lot of really nice features, but if you don''t need those features (and you usually don''t), then it''s best to use sh/bash instead.

I would also highly recommend doing shell scripting in a shell that has "experience" (one that has been around, tested, bugs worked out, etc.), and so I''d recommend sh/bash over ksh. I know I''ve had some peculiar problems with ksh scripting in the past. I had a pretty large set of scripts that analyzed apache log files that were written in ksh, and when we tried to move those scipts over to another machine, they wouldn''t run correctly, and we had to go around hunting for bugs. It turns out we were using some of the Korn shell''s lesser used features, and the different ksh binaries didn''t like something. If we had written it in the Bourne shell, I don''t think we would have had any problems.

quote: Personally, I don''t find there to anything that you can do in one that you can''t do in another that creates a scenario where you say, "I can''t live without that feature." But maybe you''ll be different. =)
The korn shell has some nice features, but like I said, unless you really need those features and you can''t get them from some other program (awk, sed, tr, etc.) then don''t bother.

If you''re on linux, you get BASH as your default shell. That''s good to script in, so start with that. It''s standard, and everyone who does shell scripting will be able to help you with that. Not everyone will know the lesser used features of the korn shell.

This topic is closed to new replies.

Advertisement