13

I normally works on Windows machines but on some occasions I do switch to development on linux. And my most recent project will be written entirely on a certain linix platforms (not the standard Apache/MySQL/PHP setup). So I thought it would pay to learn to write some linux automation script now.

I can get around the system, start/stop services, compile/install stuffs fine. Those are probably basic drills for a programmer. But if, for example, I wanted to deploy a certain application automatically to a newly minted linux machine every month I'd love to know how to do it.

So if I wanted to learn serious linux shell scripting, what book should I be reading?

HopelessN00b
  • 53,795
  • 33
  • 135
  • 209
chakrit
  • 417
  • 2
  • 6
  • 15

4 Answers4

6

online: ABS

warning: this is a bash tutorial so there are bash-only syntaxes and I recommend you to not use them.

It is though a very good documentation

zecrazytux
  • 639
  • 3
  • 7
  • 1
    Why not use bash only syntax? I've never encountered a system that doesn't have /bin/bash installed. You just have to make the shebang line appropriately #!/bin/bash – Aaron Brown Dec 09 '09 at 18:45
  • 1
    @ABrown: Up until quite recently it was very common for linux rescue modes to use `ash`, and very small distribution also tend to use stripped down shells like the busybox `sh`. – dmckee --- ex-moderator kitten Jan 29 '10 at 18:54
5

Learning the Bash Shell along with Classic Shell Scripting, followed by Bash Cookbook.

I would suggest charging through the first two books, without worrying too much about remembering it all. Reference them as you want to do something that you remember reading about but don't recall how to actually do. And come back to them a few a months later and learn new things from them.

Note, this is coming from the perspective of a linux admin, so I lean toward the niceties of bash over the more pure sh. It is only the rare script that I bother to actually make sh compatible. Also, I don't consider tcsh to be a legitimate scripting language.

Brian De Smet
  • 1,139
  • 7
  • 10
1

I bought the amazon five star rated 'Linux Command Line and Shell Scripting Bible' from Richard Blum (ISBN: 047025128X) for getting to that 'serious shell scripting' and I must say I am very impressed by the book. Gives you in depth knowledge about shell scripting but also other concepts needed in that context like how linux file system permissions work and your must-known Unix tools like grep.

Hannes de Jager
  • 744
  • 2
  • 6
  • 11
1

Shell scripting is not shell scripting. Different systems come with different shells and the differences in syntax and semantic are significant.

Others have mentioned Bash books, for Korn shell I recommend O'Reilly's Learning the Korn Shell. If you'll have to write portable shell scripts there is also from O'Reilly: Classic Shell Scripting.

In my opinion: Writing portable shell scripts is a sheer nightmare even for people that are fairly used to a certain shell. If you come from a windows background, you are familiar with the basic stuff (start/stop services, compile/install stuffs) and your goal is automation I'd personally stick with Perl.

While Perl has its flaws it is when it comes to glueing different parts together where it shines. And this is what makes up most part of automation in my experience. Moreover, on Unix systems Perl is ubiquitous.

Ludwig Weinzierl
  • 1,180
  • 1
  • 11
  • 22