![]() |
|
Programming C, bash, Python, Perl, PHP, Java, you name it. |
![]() |
|
Thread Tools | Display Modes |
|
|||
![]()
Hi folks.
I want to start experimenting with basic shell scripting. I've found several web sites that describe how to do it, and I'll be looking into them in more detail soon. But I want to know which ones you more seasoned BSD users would recommend. My supply of free time tends to fluctuate, so for now I want to stick with simple stuff. I want to start with scripts that essentially do what the old DOS *.bat files did. That is, execute a set of standard shell commands to complete a common task. I'm not ready for pipes, parameters and other such stuff. I'll get to those later on. Thanks in advance, RJPugh |
|
||||
![]()
First things first ... always use #! /bin/sh as script interpreter.
As for the guides, check these for start: http://developer.apple.com/library/m...roduction.html http://www.grymoire.com/Unix/Sh.html http://www.unix.com/tips-tutorials/1...arse-file.html http://www.ibm.com/developerworks/ai...GoodUnixHabits http://sparky.rice.edu/~hartigan/sed.html http://sparky.rice.edu/~hartigan/awk.html http://www.ibm.com/developerworks/li...wk1/index.html http://www.shell-fu.org/lister.php?top http://www.commandlinefu.com/ Shell scripting is generally about efficient parsing/altering the output of commands with sed/awk/cut/find/column/grep/... and using PIPES a lot.
__________________
religions, worst damnation of mankind "If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”. vermaden's: links resources deviantart spreadbsd |
|
||||
![]()
The following web-site and pages linked to it contains probably all the information you will ever need about the shell scripting.
http://www.shelldorado.com/links/ Call me and old fashion guy but I would by a book. My favorite is Classic Shell Scripting by Nelson H.F. Beebe, Arnold Robbins and if you like me use Korn Shell (pdksh with OpenBSD enhancements also branded by some people removed from OpenBSD project as Mir Korn Shell mksh) Learning the Korn Shell, First Edition by Bill Rosenblatt (the second edition is worse and done after Bill's death). I also like Unix Shell Programming, Third Edition by Stephen G. Kochan, Patrick Wood. You can find on the Internet original Stephen's notes under the name An Introduction to the UNIX shell. And of course the most important advise as with any programming is that unless you do scripting you are not going to learn it. |
|
|||
![]()
I don't use sh much other than as an interactive shell (actually I kind of dislike shell script, along with Makefile syntax and its various macro/extension packages), but I thought this was a good book:
_The Unix Programming Environment_ Kernighan and Pike. |
|
||||
![]()
It is a VERY good introductory book on Unix as a whole but it is too short too cover any particular topic in great depth. However, highly recommended as the first reading for any novice Unix user.
Last edited by Oko; 9th June 2011 at 02:08 AM. |
|
|||
![]()
I like Chris F.A. Johnson's "Shell Scripting Recipes", though I don't recall at this moment which shell it discusses.
Personally, I would say that shell programming knowledge develops in these stages: 1. A list of commands executed in sequence 2. Same as #1 but verbosely telling the user what's doing and maybe writing to a log file 3. A situation where you might want something to happen, so you learn about if and maybe case 4. You realize you need to consider some input more deeply, so you need to learn basic text processing (cut, sed, maybe simple awk) and variables 5. You decide to make your program somewhat interactive so there's user processing 6. Very soon after, you learn more about error handling because users make mistakes :-) 7. Your programs get bigger and now you're into functions, little libraries, etc. You are using variable scoping, coroutines, arrays, and lots more awk, sed, etc. Maybe you go crazy and start using tput to write interactive curses menus :-) 8. You've outgrown shell and move on to perl, python, ruby, or really move on and start writing C. I am not entirely serious about #8. I've maintained multi-thousand-line shell scripts and with enough programmer discipline, you can write huge things in shell. |
|
|||
![]()
8. read books on formal specification languages, take a sabbatical, teach yourself JSP, write COBOL programs for a while, return to posix SH and write highly competent command line utils using structured programming techniques and a strict procedural style
![]() 9. get a job as a C programmer |
![]() |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Book(s) for learning C as a first language? | guitarscn | Programming | 10 | 12th December 2010 02:34 PM |
Learning how to program | Solaris_Delta | Programming | 9 | 24th December 2008 07:58 PM |
Learning Content Management System | Oko | General software and network | 0 | 31st October 2008 04:02 AM |
Learning Programming | Crypt | Programming | 35 | 27th October 2008 04:54 PM |
Learning Perl | mtx | Book reviews | 7 | 22nd October 2008 05:55 PM |