Author |
Message |
cgit.. #1 / 11
|
 Good manuals on shell programming
I have been using UNIX for about 1.5 years now, mainly for writing C programs and such. Recently I started writing small shell scripts (csh). I would really like to learn more about shell programming. What I am looking for is recommendations of good manuals/books on shell programming. I would prefer it to be about csh as that it what I am used to, but I would welcome suggestions about any. Thanks! p.s. Please post replies to net or send to cgit...@riemann.gsfc.nasa.gov
|
Sat, 22 Jan 1994 22:58:00 GMT |
|
 |
Tony J Yeat #2 / 11
|
 Good manuals on shell programming
The csh Bible is "The UNIX C Shell field guide" by Gail & Paul Anderson - its a very good book. **** I use "the KORNSHELL Command and Programming Language" for Ksh, I really didn't much care for this book at first (the index sucks, I find it hard to locate info. and the explanations and examples are often poor), but its growing on me, a little. ** Don't try and struggle by w/o a book, a book will save you considerable time. I use tcsh (new, improved csh) as my login shell, but if you are going to being doing a lot of shell programming, I would recommend taking a look at ksh. Ksh generally handles super long command lines (e.g. grep 'something' <a very long list of files> ) where csh and tcsh don't - I have found this a major drawback on several occassions. Ksh also has some other nice features, like pattern matching features, although the case/switch command is not as good as csh (can't "fall thro'" to the next "case") and the "until" iteration command seems to be particularly lame (if not redundant). I suspect that some of the new ksh features e.g. [[]] $() and $(<) make ksh scripts considerably faster that csh scripts, but I have no proof of it. My 2p worth.
|
Sun, 23 Jan 1994 05:19:28 GMT |
|
 |
Tom von Alt #3 / 11
|
 Good manuals on shell programming
I had my choice of Bourne shell and csh when I first started, and learned the script syntax for the former, even though I used csh for a shell. At the time, I think that "backwards compatibility" was on my mind. I've since graduated to ksh, and am glad I never wasted time learning csh syntax (Ksh syntax is consistent with sh syntax). I think ksh is a better shell, too.
|
Mon, 24 Jan 1994 03:00:03 GMT |
|
 |
Eric Gis #4 / 11
|
 Good manuals on shell programming
In article <1991Aug7.110023.27...@cbnewsh.cb.att.com>, b...@cbnewsh.cb.att.com (barbara.tongue) writes:
Try looking for the special rules that "read" uses for IFS splitting. (You can read files like /etc/passwd with IFS=:, and empty fields are handled). And I still haven't found out where is mentions special ~ expansion rules for PATH assignments. You have to scan the whole book to find these and others.
|
Tue, 25 Jan 1994 00:59:12 GMT |
|
 |
Chet Ram #5 / 11
|
 Good manuals on shell programming
Stop looking, they're not in there. Korn wanted to do away with the special PATH tilde expansion hack altogether, and the initial versions of ksh-88 did not include it. He had to put it back after too many users complained. Chet -- ``Someday soon, I'm gonna tell the world about the crying game...'' Chet Ramey Internet: c...@po.CWRU.Edu Case Western Reserve University NeXT Mail: c...@macbeth.INS.CWRU.Edu
|
Tue, 25 Jan 1994 04:12:48 GMT |
|
 |
Martin Foo #6 / 11
|
 Good manuals on shell programming
In article <7...@coal5.UUCP> yea...@motcid.UUCP (Tony J Yeates) writes:
Don't use the csh as a scripting language - it's full of bugs, anomalies etc. etc. etc. Use it freely as an interactive shell (although there are better PD things{*filter*} around on the net ie: zsh, bash, tcsh). ksh is a great language for programming, but it's not a good idea if you want portability (no doubt ksh will start to spread to more machines). The bourne shell is on every UNIX machine, has most features you want for programming are there (unlike the csh ...). Go for it. The manual entry (if one can understand it) has all the info you'll need. Martin. -- Martin Foord. MHSnet/ACSnet: m...@dbsm.oz.au SBC Dominguez Barry. Internet Gateway: Phone: +61-2-258-2724 maf%dbsm.oz...@munnari.oz.au
|
Fri, 28 Jan 1994 07:31:27 GMT |
|
 |
Tom von Alt #7 / 11
|
 Good manuals on shell programming
In comp.unix.shell, c...@odin.INS.CWRU.Edu (Chet Ramey) writes:
I just started looking at this book, and in the Introduction, one of the touted features is: "Tilde Expansion. The home directory of any user, and the last directory that you were in, can be referred to symbolically...." I didn't know about the last directory, but now you tell me it's not explained in the book?? Sheesh. At least it's in our man page: ~alien => alien's home directory ~ => "my" home directory ~+ => $PWD ~- => $OLDPWD (I didn't know about this one)
|
Tue, 01 Feb 1994 02:40:37 GMT |
|
 |
lawrence.v.cipria #8 / 11
|
 Good manuals on shell programming
Page 146 of The Kornshell Command and Programming Language book says: ... Version: In the 06/03/86 and earlier versions of ksh, tilde substitution was attempted after each : within the value of an assignment statement. So, for example the following: PATH=/bin:/usr/bin:~/bin: is equivalent to: PATH=/bin:/usr/bin:$HOME/bin: Also, it's not limited to the PATH variable. At one point during the beta test of ksh, Korn took this feature out, but since so many people who were using it by then complained, it was put back [I think this was around the time the book was being written]. So, as far as I can tell, the book should not list this as a version specific feature. -- Larry Cipriani, att!cbvox1!lvc or l...@cbvox1.att.com "Fight fire with fire, I always say." -- Bugs Bunny
|
Wed, 02 Feb 1994 01:23:47 GMT |
|
 |
Chet Ram #9 / 11
|
 Good manuals on shell programming
You misunderstand. The Korn shell will magically expand tildes that appear after unquoted colons (or maybe it's unquoted tildes after colons) in assignments to PATH. This does not obey the normal tilde-expansion-at- the-start-of-a-word rule, and it's not in the book. Korn did try to remove this `feature', but had to put it back. Chet -- ``Someday soon, I'm gonna tell the world about the crying game...'' Chet Ramey Internet: c...@po.CWRU.Edu Case Western Reserve University NeXT Mail: c...@macbeth.INS.CWRU.Edu
|
Wed, 02 Feb 1994 02:22:55 GMT |
|
 |
Dan_Jacob.. #10 / 11
|
 Good manuals on shell programming
Chet> You misunderstand. The Korn shell will magically expand tildes Chet> that appear after unquoted colons (or maybe it's unquoted tildes Chet> after colons) in assignments to PATH. This does not obey the Chet> normal tilde-expansion-at- the-start-of-a-word rule, and it's Chet> not in the book. This "for" loop seems to work... #set dummy ~exptools/adm/bin ~unison/bin $directories; shift #didn't work for i in ~exptools/adm/bin ~unison/bin do directories=$directories\ $i; done #get tilde expansion for i in $directories do #don't add it to PATH if already there case $nPATH in *:$i:*|*:$i|$i:*|$i) continue; esac #see if the directory really exists test -d $i && nPATH=$nPATH${nPATH+:}$i done PATH=$nPATH
|
Thu, 03 Feb 1994 06:59:28 GMT |
|
 |
Paul D. Swas #11 / 11
|
 Good manuals on shell programming
Although your method is probably better (keeping only one copy of each directory ... not adding directories that don't exits...) I have to set several path-like variables so I use something like: list () { IFS=: echo "$*" } PATH=$(list ~/bin /bin /usr/bin) CDPATH=$(list ~ ~/src ~/docs) This works with both BASH and ksh. -dave ps...@andrew.cmu.edu R746P...@VB.CC.CMU.EDU
|
Thu, 03 Feb 1994 18:29:15 GMT |
|
 |
|