Slashdot Mirror


Bash Cookbook

Chad_Wollenberg writes "Anyone who has used a derivative of Unix over the past 20 years has used Bash, which stands for Borne Again Shell. The geek in all of us makes us want to extend our ability to rule the command line. To truly master a Unix environment, you need to know a shell, and Bash is easily the most popular of them. Any Unix/Linux/BSD administrator knows the power at your fingertips is fully extended by what you can do within the Bash environment, and all of us need the best recipes to get the job done." Keep reading for the rest of Chad's review. Bash Cookbook author Carl Albing, JP Vossen, Cameron Newham pages 598 publisher O'Reilly rating 9 reviewer Chad Wollenberg ISBN 978-0-596-52678-8 summary A good book for intermediate and above users of Bash Enter Bash Cookbook. Properly named for the series of O'reilly books that gives you valuable information on subjects in the form of recipes, this book was refreshing in that it was properly organized, and surprisingly contemporary, even citing Virtualized platforms as a way to try out different OS's for Bash. The book does a good job of pointing out the different operating systems that do run Bash, even citing Cygwin for Windows. They also use the POSIX standard, so that all of the examples are portable across platforms.

Bash Cookbook is by no means for the feint of heart. It seems that the book is meant for intermediate and above users of Bash. However, the first several chapters do a significant job of over viewing basic concepts of Bash navigation and combing simple commands. The book quickly changes gears to complex statements on how to get things done in Bash.

By Chapter 7, Bash Cookbook extends out of Bash commands and begins exploring combining the power of bash scripting with useful command such as grep, awk, and sed. To quote the authors, "if our scripting examples are going to tackle real-world problems, they need to use the wider range of tools that are actually used by real-world bash users and programmers." And that is exactly what they do. This chapter alone gave me the ability to do more in the command line environment simply by explaining the functions of the scripts put forth. That is something that any reader, intermediate to expert, can take from this book. The detailed explanations really do give everyone the ability to learn something about the commands, and the references to additional resources often lead me to the computer, looking up further details.

I found Chapter 11 to be very useful (pun intended) finally grasping some concepts on the find command that have previously escaped me. From Chapter 12 on, the book focuses on writing useful and complex scripts. This is where the book really begins to shine for the Unix enthusiast and system administrator. The scripts found in Chapter 12, and their elaborate descriptions begin to show the true power of Bash scripting, and how much you can automate. Chapter 14 is about securing your scripts, and is a heavy read, but well worth reading for any administrator that would be using their scripts in a production environment.

Just when you think this book has reached its limits, it gives very handy customization examples in Chapter 16 on how to configure and customize Bash. And also goes into common mistakes made by the novice user. Combine all of that with the Appendices for quick reference, and this book has not left my side since it arrived. While I would not recommend this book for the novice user, I would recommend this book to any system administrator that has to work with Unix or Linux. If nothing else, the examples given here are full of good, reusable code to make tasks easier in your day to day functions. Well done.

You can purchase Bash Cookbook from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

278 comments

  1. BASH != Bourne Shell by llamalad · · Score: 4, Informative

    'sh' is the Bourne shell.
    'bash' is the Bourne Again SHell.

    They're not the same.

    1. Re:BASH != Bourne Shell by laejoh · · Score: 5, Funny

      It doesn't matter. If you code like I do you don't need to worry about the difference between /bin/sh and /bin/bash:

      <begin file A>
      #!/bin/bash

      perl <<EOP
      print "hello world\n";
      EOP
      <end file A>

      <begin file B>
      #!/bin/sh

      perl <<EOP
      print "hello world\n";
      EOP
      <end file B>

      See? Both work, it's so easy!

    2. Re:BASH != Bourne Shell by Anonymous Coward · · Score: 0

      Who implied that they were the same?

    3. Re:BASH != Bourne Shell by againjj · · Score: 2, Informative

      Except for the fact that sh is generally symlinked to bash on Linux systems:
      $ ls -l /bin/sh
      lrwxrwxrwx 1 root root 4 Mar 10 2006 /bin/sh -> bash

    4. Re:BASH != Bourne Shell by dashesy · · Score: 0, Offtopic

      Now I get that! Bush Bashing means having Bush fight with Jason Bourne in a new shell.

    5. Re:BASH != Bourne Shell by WillKemp · · Score: 4, Informative

      Except for the fact that sh is generally symlinked to bash on Linux systems:

      True. But if bash is invoked as 'sh', it works like sh.

    6. Re:BASH != Bourne Shell by dfn_deux · · Score: 2, Insightful

      An interesting observation, which also points out something that I noticed in the review text. He says that all the scripts in the book are "POSIX" compliant, but AFAICT bash extends the POSIX standard bourne shell "/bin/sh" with a bunch of features which are not part of the posix standard. Calling bash from a "sh" symlink starts bash in POSIX compliance mode wherein it acts exactly like a standard bourne shell. It seems if the book has strictly POSIX friendly scripts that it isn't really a bash book so much as it is a bourne shell book.

      --
      -*The above statement is printed entirely on recycled electrons*-
    7. Re:BASH != Bourne Shell by timonvo · · Score: 1

      So that means that everything that is backwards compatible/compatible with some other software is identical to that software?

    8. Re:BASH != Bourne Shell by llamalad · · Score: 0, Offtopic

      Who implied that they were the same?

      Um, the first line of the summary?

      "Anyone who has used a derivative of Unix over the past 20 years has used Bash, which stands for Borne Again Shell."

      'sh' has been shipping with UNIX operating systems for ages; 'bash' has only recently.

      IIRC, it didn't ship with Solaris 7 and I know that Solaris 8 at the very least didn't have it installed by default. Do believe it's installed as part of Solaris 9 and above. As far as AIX goes, I'm guessing bash only came in with 5L. HPUX... yeah, right.

    9. Re:BASH != Bourne Shell by Benanov · · Score: 5, Informative

      In Ubuntu since edgy, sh has been symlinked to dash instead. This allowed for a much faster boot while breaking all the "sh" scripts that used bash-specific syntax.

      There was a bunch of whining about it when it happened but I think everyone fixed their scripts and shut up.

    10. Re:BASH != Bourne Shell by mgessner · · Score: 2, Informative

      It doesn't say they're the same.

      However, it's "Bourne Again SHell."

      --
      "Sometimes the truth is stupid." - Lawrence, creator of Prime Intellect
    11. Re:BASH != Bourne Shell by llamalad · · Score: 1

      It doesn't say they're the same.

      That's right. But it does imply that they're the same.

      "Anyone who has used a derivative of Unix over the past 20 years has used Bash, which stands for Borne Again Shell."

      The implication that 'bash' has been shipping with the majority of UNIX-like operating systems for 20 years betrays the submitter's failure to distinguish between 'sh' and 'bash'.

      Hence with the pointing out that they're not the same.

    12. Re:BASH != Bourne Shell by againjj · · Score: 4, Informative

      No, it doesn't. There are a couple of changes, like ~/.bashrc is not read, but mostly it stays as-is. Basically, if you invoke bash as sh, AND stay inside the sh syntax/commands, then bash works like sh.

      -sh-3.00$ /bin/sh
      sh-3.00$ help bind
      bind: bind [-lpvsPVS] [-m keymap] [-f filename] [-q name] [-u name] [-r keyseq]
      [-x keyseq:shell-command] [keyseq:readline-function or readline-command]
      Bind a key sequence to a Readline function or a macro, or set
      a Readline variable. The non-option argument syntax is equivalent
      to that found in ~/.inputrc, but must be passed as a single argument:
      bind '"\C-x\C-r": re-read-init-file'.
      [...]
      sh-3.00$ echo $PS1
      \s-\v\$
      sh-3.00$ export PS1='myprompt '
      myprompt export PS1='\s-\v\$ '
      sh-3.00$ exit
      exit
      -sh-3.00$

      Here, bind and PS1 (help maybe?) are both in bash but not sh.

    13. Re:BASH != Bourne Shell by Krishnoid · · Score: 4, Informative

      Generally -- except in one notable case, and expected in Debian lenny. As you can imagine, this caused a lot of complaints. From what I skimmed there and other places, the attitude is that /bin/sh under Debian should be a fully POSIX-compliant shell, and if you want to use bashisms, start your program with #!/bin/bash.

    14. Re:BASH != Bourne Shell by lmnfrs · · Score: 2, Informative

      Apparently, even while in POSIX mode, bash isn't quite POSIX-compliant: http://www.gnu.org/software/bash/manual/html_node/Bash-POSIX-Mode.html

    15. Re:BASH != Bourne Shell by Anonymous Coward · · Score: 0

      Not necessarily. This is why problems have arose because Ubuntu and Debian decided to move to dash.

    16. Re:BASH != Bourne Shell by Anonymous Coward · · Score: 1, Informative

      True. But if bash is invoked as 'sh', it works like sh.

      More or less, I suppose, but not exactly; at least, not in my experience. A while back I decided to make /bin/sh a symlink to dash instead of bash (part of a quixotic quest to rid my Linux system of GNU software). A good number of scripts broke, because they used bashisms that bash happily accepted even when it was /bin/sh, but dash rejected.

      Thus part of the quixotic nature of my quest: I simply patched those programs to use /bin/bash, meaning it's still around. Not as my Bourne shell, though!

    17. Re:BASH != Bourne Shell by alexborges · · Score: 1

      Your script does not scale.

      --
      NO SIG
    18. Re:BASH != Bourne Shell by techno-vampire · · Score: 1

      No. It shows that the submitter thought bash had been around for much longer than it has. Nothing more.

      --
      Good, inexpensive web hosting
    19. Re:BASH != Bourne Shell by swillden · · Score: 2, Insightful

      That fact does cause a lot of problems with poorly-written third-party scripts, though. I spent two full days scratching my head over why I couldn't run the IBM Rational Software Architect installation program on my Ubuntu box, even though it had worked just fine on Debian. Finally I realized that the installation script used BASH features, but tried to run under /bin/sh.

      That's just one example, and it's the installer that's at fault, not Ubuntu, but I've run into enough of them that I make a habit of changing the /bin/sh symlink on every Ubuntu system that I install. There's just too much crud that thinks "/bin/sh" means BASH.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    20. Re:BASH != Bourne Shell by eldepeche · · Score: 3, Informative

      According to Wikipedia, Bash was first released in 1987, 21 years ago. I have no idea when it became the predominant shell in GNU/Linux-world.

    21. Re:BASH != Bourne Shell by eldepeche · · Score: 2, Funny

      Why did you want to get rid of all GNU software? Could you smell RMS's beard on it?

    22. Re:BASH != Bourne Shell by Macka · · Score: 1

      That fact does cause a lot of problems with poorly-written third-party scripts

      You mean scripts written by clueless idiots who have no business writing installation scripts if they don't know that 'sh' != bash and != POSIX. "sh" is as old as the hills and has a very limited feature set: it always has. Personally I've not run into this yet, but I'd stick a rocket up the arse of anyone who sent me a product that wouldn't install because of a basic, newbie mistake like that.

    23. Re:BASH != Bourne Shell by swillden · · Score: 4, Funny

      I'd stick a rocket up the arse of anyone who sent me a product that wouldn't install because of a basic, newbie mistake like that.

      You'd need a lot of rockets. In my experience, this sort of error is very, very common.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    24. Re:BASH != Bourne Shell by Anonymous Coward · · Score: 0

      That was a pain in the ass.

    25. Re:BASH != Bourne Shell by Anonymous Coward · · Score: 1, Insightful

      Except for the fact that sh is generally symlinked to bash on Linux systems:

      True. But if bash is invoked as 'sh', it works like sh.

      Sometimes. Other times it works like bash.

      Really annoying to those of us on BSD and Solaris. If you want to use bash, just specify bash, otherwise the GNU folks really need to clean things up.

      Ditto for GNU make.

    26. Re:BASH != Bourne Shell by Fujisawa+Sensei · · Score: 1

      Why did you want to get rid of all GNU software? Could you smell RMS's beard on it?

      Its to build a system with that Linux doesn't need GNU and shove the GNU/Linux BS right back at RMS's beard.

      --
      If someone is passing you on the right, you are an asshole for driving in the wrong lane.
    27. Re:BASH != Bourne Shell by imscarr · · Score: 1

      Wow! That is so cool!
      I bet that may even work with a C-shell or a Korn Shell. :)

      --
      Like the beaver, it's just Dam one thing after another
    28. Re:BASH != Bourne Shell by ConceptJunkie · · Score: 1

      Hey, it's IBM we're talking about here. You're lucky it doesn't use REXX or something like that. I've never seen a piece of IBM software that was more user friendly than a pissed-off rattlesnake.

      --
      You are in a maze of twisty little passages, all alike.
    29. Re:BASH != Bourne Shell by dindi · · Score: 1

      #!/usr/bin/perl
      print "hello world\n";

      I just made your five lines of code into 2. I won.

    30. Re:BASH != Bourne Shell by A+Numinous+Cohort · · Score: 1

      Actually, I remember that some IBM software I installed used the Korn shell and run quite well, even accepting mouse clicks as input on the terminal.

    31. Re:BASH != Bourne Shell by CrazedWalrus · · Score: 2, Insightful

      This just bit me in the ass a couple weeks ago. Debian/Ubuntu don't symlink to bash, which is what I'd assumed. They symlink to "dash" -- a stripped-down shell where stuff you expect to work doesn't.

      For the life of me I couldn't figure out why my perfectly valid bash one-liner in my crontab wouldn't work. Some Googling and cursing Debian later, and /bin/sh -> /bin/bash, and my cron jobs are working as expected.

      Now, someone can disagree with me here, and I know you will. The stated purpose of this change is performance gains. Really? Performance gains on shell scripts that rarely go over a couple hundred lines and do all the grunt work in other utilities?

      I'm sure someone came up with a benchmark showing how dash is 100x faster than bash, but in real-world examples, I have to doubt there's any noticeable difference. That said, all the time saved by dash running faster was lost completely when I had to waste my time figuring out what in the hell was wrong with cron.

      Grr.

      </rant>

    32. Re:BASH != Bourne Shell by Anonymous Coward · · Score: 1, Informative

      I'm the poster to whom you replied (honest!)

      Why did you want to get rid of all GNU software? Could you smell RMS's beard on it?

      My primary reason for wanting to ditch GNU software is because of GNU's attitude toward man pages. That is, they think they should be replaced by info pages. Unfortunately, info documentation tends to read like a book, with sections about all sorts of various things that, honestly, I don't give a damn about when I'm looking for a brief synopsis of a program. You know what, historically, has given a good synopsis of a program? Man pages. So I decided to port over as much BSD software as I could because the BSDs still care about the kind of documentation I like.

      Did you know that GNU tar doesn't ship with a man page? Not even one of those crappy "see the info page for the full documentation" pages. Yes, you might have one on your system, but it did not come from GNU; or if it did it's either wildly out of date (I don't know when, if EVER, they shipped a tar man page) or updated by your distribution.

      There's also the annoyance of the term GNU/Linux. Yes, I understand why people push for it, but something about GNU adherents rubs me the wrong way. Anything I can do to legitimately make my system not "GNU/Linux" is a positive step. So I suppose the answer to your question is "yeah, kind of".

      Plus the BSD license gives me more freedom than the GPL.

    33. Re:BASH != Bourne Shell by cerberusss · · Score: 1

      According to Wikipedia, Bash was first released in 1987, 21 years ago. I have no idea when it became the predominant shell in GNU/Linux-world.

      It became the predominant shell when bash became sentient at 2:14am on August 29, 1997, inserting itself in all major Linux distributions.

      --
      8 of 13 people found this answer helpful. Did you?
    34. Re:BASH != Bourne Shell by Wdomburg · · Score: 1

      But... but... you can make that so much shorter in bash!

      <begin super sweet optimized version>
      #!/bin/bash

      perl <<< print '"hello world\n"'
      <end super sweet optimized version>

    35. Re:BASH != Bourne Shell by ahsile · · Score: 1

      That's why my scripts broke when I went from dapper to hardy... I just fixed them since I figured it was somehow my fault.

    36. Re:BASH != Bourne Shell by neurovish · · Score: 1

      I also remember "helping" to install some IBM software that used korn shell on a SLES machine. The problem was, SLES used pdksh (which is mostly ksh88), and IBM was expecting ksh93, so the installer kept failing and confused the hell out of whoever was initially trying to install it.

    37. Re:BASH != Bourne Shell by n7kv · · Score: 1

      'sh' is the Bourne shell. 'bash' is the Bourne Again SHell.

      They're not the same.

      Thank you.

    38. Re:BASH != Bourne Shell by Anonymous Coward · · Score: 0

      It became the predominant shell when I started using it. I'll let you know next year what the predominant shell is if I decide to switch.

    39. Re:BASH != Bourne Shell by ConceptJunkie · · Score: 1

      And that's why you can never go wrong with Windows. cmd.exe (nee command.com) hasn't had any significant changes (and no improvements) in 15 years (or so it seems, I stopped using the standard MS shell almost 20 years ago).

      Lowest Common Denominator FTW.

      --
      You are in a maze of twisty little passages, all alike.
  2. "feint" of heart? by Tetsujin · · Score: 4, Funny

    So, what, does this refer to people who act like they're going to rip your heart out of your chest, only it all turns out to be a ruse so they can kick you in the balls?

    --
    Bow-ties are cool.
    1. Re:"feint" of heart? by straponego · · Score: 1

      The "feint" is a feint; it draws your attention from the next sentence: However, the first several chapters do a significant job of over viewing basic concepts of Bash navigation and combing simple commands.

      Over viewing? Is that viewing too much? Combing simple commands? I could go on, but I can't go on.

  3. Bourne-Again Shell by cos(0) · · Score: 4, Informative

    Bourne Again Shell, not Borne.

    1. Re:Bourne-Again Shell by Kingrames · · Score: 0, Offtopic

      And before anyone asks, no it's not the next installment in the movie series starring Matt Damon.

      --
      If you can read this, I forgot to post anonymously.
    2. Re:Bourne-Again Shell by Ecuador · · Score: 5, Funny

      Seriously now, this is like posting a LOTR review by someone who thinks it was written by RJ Tokelen. Or a Star Trek review from a fan of "the late Rod N. Barry".
      You gotta love our editors!

      Anyway, back to my review of Dark Night... Chris Nolon did it again!

      --
      Violence is the last refuge of the incompetent. Polar Scope Align for iOS
    3. Re:Bourne-Again Shell by Comboman · · Score: 1, Funny

      Bourne Again Shell, not Borne.

      Are you saying the poster had a problem with The Bourne Identity?

      --
      Support Right To Repair Legislation.
    4. Re:Bourne-Again Shell by vrmlguy · · Score: 1

      Bourne Again Shell, not Borne.

      Do we need to issue an ultimatum concerning this betrayal? The supremacy of that identity is vital, and I'll sanction anyone disrespecting its legacy.

      --
      Nothing for 6-digit uids?
  4. What about the Advanced Bash Scripting Guide? by UltraMathMan · · Score: 5, Informative

    Not knocking the book, especially as I haven't read it, but I've found the Advanced Bash Scripting Guide (available free online) http://tldp.org/LDP/abs/html/ extremely helpful on numerous occasions.

    --
    Registered Linux User #423733
    1. Re:What about the Advanced Bash Scripting Guide? by Jansingal · · Score: 2, Insightful

      even though there is a lot of free info, some people like a hard copy of something.

      yeah, you could print the same info, but it is not bound, etc.

    2. Re:What about the Advanced Bash Scripting Guide? by UltraMathMan · · Score: 1

      Sure, but I find that when I'm scripting it's generally on a computer - IMHO it's easier to reference something online (and to find it) than it is by combing a 598 page printed book.

      Don't get me wrong, books have a place too, but I can't run a find on my printed copy. My intention was to point out that good free resources exist and, at least in this case, are well maintained.

      --
      Registered Linux User #423733
    3. Re:What about the Advanced Bash Scripting Guide? by iminplaya · · Score: 1

      That was the first place I went after seeing the price of the book. This appears to be yet another ad for Amazon.

      --
      What?
    4. Re:What about the Advanced Bash Scripting Guide? by iminplaya · · Score: 1

      802 pages. Get a very big stapler.

      --
      What?
    5. Re:What about the Advanced Bash Scripting Guide? by WillKemp · · Score: 1

      Both forms have their advantages. The benefit of a hardcopy book is that you can sit down, away from the computer, and read it sequentially (if you're that way inclined!). That way, if you read the whole thing and the book's good, you get the whole picture.

      I dunno about you, but i'm rarely capable of reading a big online document from start to finish. I tend to pick out bits i need to know about. That means i miss out on things i don't know i need to know.

      But you can't grep a hard copy!

    6. Re:What about the Advanced Bash Scripting Guide? by Jansingal · · Score: 1

      u r right there.

      but for the folks that have an hour on a bus/train to work each direcction, this is good reading material.

    7. Re:What about the Advanced Bash Scripting Guide? by Jansingal · · Score: 1

      good point.

    8. Re:What about the Advanced Bash Scripting Guide? by Anonymous Coward · · Score: 0

      Ouch, what the fuck man, learn how to type.

    9. Re:What about the Advanced Bash Scripting Guide? by Anonymous Coward · · Score: 0
      Ouch, what the fuck man, learn how to type.

      .

      Sorry. I tried 'man type' but I got back something about builtin, so I gave up.

    10. Re:What about the Advanced Bash Scripting Guide? by Anonymous Coward · · Score: 0

      when I'm scripting it's generally on a computer

      Pussy! I script in my mind, then just say it aloud. VT100 does the rest, without any error.

    11. Re:What about the Advanced Bash Scripting Guide? by computational+super · · Score: 1

      I read that a lot - "why buy a book when there's so much information online for free?" I wonder if some people (like me) just suffer from more eyestrain when reading on a computer. I find reading printed documentation less painful on the eyes than onscreen documentation, so I prefer it... do you not notice any difference? Just curious.

      --
      Proud neuron in the Slashdot hivemind since 2002.
    12. Re:What about the Advanced Bash Scripting Guide? by jc42 · · Score: 1

      I read that a lot - "why buy a book when there's so much information online for free?"

      Yeah; and I like to use that as an intro to explaining just why people do that.

      My favorite example is to suggest walking into any of the tech bookshops that have popped up in many academin and high-tech areas in the past decade or so. They typically have several showcases inside the door that display the top sellers. If you open any of them and scan through all the usual publishers boilerplate, preface, etc., you'll typically find a URL that you can use to download a PDF of the book. For free.

      This is interesting. You can get all the contents online for free, but the books are best sellers. What's going on here? Do people really pay for books when they can download the contents for free?

      The publishing industry is slowly waking up to the fact that the answer is "Yes." There is a lot of value to electronic copies of books. But there's also a lot of value to a real book. Books aren't obsolete. They are just somewhat more limited before, restricted to the situations where hard copy has an advantage over electronic text.

      One example that I like to use: I've worked in a lot of software development labs, where we have a flock of "crash and burn" machines for testing purposes. Typically each machine has a sign on it saying what is installed at the moment -- and a stack of printed manuals at the side. The fact is, when a machine is in a flaky state because of the half-tested software installed, you often find that you can't reach the network. So you'd better have the manuals there in printed form. That's all you have. (Actually, you usually have some nearby machines that can reach the network, but you've learned that it's not all that good an iidea to realy on that. ;-)

      Other examples abound. I remember a few years ago, when I was involved in playing for a music/dance workshop in the wilds of the Berkshires, and someone asked "Can you play the tune for XXX?" While the other musicians tried to think of the standard tune, I whipped out my smartphone, connected to my website, downloaded the tune, and told the phone to play it. The other musicians said "Oh, yeah; that tune." I got instant geek points, and we played the tune. But frankly, here in the US, wireless Internet access is so spotty, due to the phone companies' desire to wring every last cent out of access, that this works in less than 1% of the landscape. It was pure luck that I had connectivity there. Despite having equipment that can do such things, I still tend to carry along copies of the most useful books to such events. Given the recalcitrance of the comm companies to give us universal wireless access, I estimate that it'll be decades before the Internet is useful in out-of-the-way places like this.

      In general, there are good reasons for printed books. Most of those reasons won't be going away any time soon. Some of them won't go away ever. Publishers can take some comfort in this. They should also be aware that they do need to look seriously at this new "publishing" medium, and learn to use it. Those who do will prosper; those who don't will fade away.

      It is fun to point out that, in the high-tech arena, hard-copy publishing is thriving.

      --
      Those who do study history are doomed to stand helplessly by while everyone else repeats it.
    13. Re:What about the Advanced Bash Scripting Guide? by Anonymous Coward · · Score: 0

      I confirm: I guess you have enough matter to chew with the fantastic Advanced Bash Scripting Guide before you might need to go search somewhere else...
      There is also a good web resource called something like the "wicked script collection" or so, which give a very good bootstrapping in the world of bash + unix toolbox

  5. BOURNE by homb · · Score: 1

    It's not " Borne Again Shell", but "BOURNE Again Shell".
    Stephen Bourne created sh from which bash is derived.

    1. Re:BOURNE by ArsonSmith · · Score: 4, Funny

      It's the Born again Bourne Again shell. Now with more Jesus.

      --
      Paying taxes to buy civilization is like paying a hooker to buy love.
    2. Re:BOURNE by pandrijeczko · · Score: 2, Funny

      Is that the one-and-only time that you will be telling us this information.

      Because if it is, then you have just issued a BOURNE ULTIMATUM!!! ...I'll get my coat.

      --
      Gentoo Linux - another day, another USE flag.
    3. Re:BOURNE by maxume · · Score: 2, Funny

      Crackers or wine?

      --
      Nerd rage is the funniest rage.
    4. Re:BOURNE by Anonymous Coward · · Score: 0

      *slow clap*

    5. Re:BOURNE by Google85 · · Score: 1

      It's the Born again Bourne Again shell. Now with more Saint IGNUcius

      There, fixed that for you.

    6. Re:BOURNE by Debian+Cabbit · · Score: 2, Funny

      Yes. Just don't fsck without intending to mkfs, or you'll be sent straight to /dev/null.

  6. Bourne shell by Z00L00K · · Score: 1


    :

    echo "I'm an old Bourne Shell"
    echo "Early on the first line was a colon to indicate a bourne shell"
    echo "And that was before the convention of #!/bin/sh"

    --
    If builders built buildings the way programmers wrote programs, then the first woodpecker would destroy civilization.
  7. Nice review, but I don't understand something. by gardyloo · · Score: 5, Interesting

    I may even buy the book based on the review.

    Leaving aside stuff like not for the feint of heart, which is just poor editing, what the hell does I found Chapter 11 to be very useful (pun intended) mean?

          Maybe it's the ultimate meta-pun, where there was no pun in the first place, but the author pointed out that one was intended, so one was slipstreamed into the statement.

    1. Re:Nice review, but I don't understand something. by Anonymous Coward · · Score: 0

      Chapter 11--> Bankruptcy.

    2. Re:Nice review, but I don't understand something. by pandrijeczko · · Score: 1

      It's been out a while but definitely worth the money.

      Even "Linux Format" magazine here in the UK gave it 10/10 in a review a few months ago.

      --
      Gentoo Linux - another day, another USE flag.
    3. Re:Nice review, but I don't understand something. by dlgeek · · Score: 1

      He continues to say he learned stuff about the "find" command which I assume the chapter focuses on.

    4. Re:Nice review, but I don't understand something. by Jansingal · · Score: 1

      >>Chapter 11--> Bankruptcy.

      what do you mean?

    5. Re:Nice review, but I don't understand something. by techstar25 · · Score: 5, Funny

      Why is everybody bashing his review?

      Okay, somebody had to say it.

    6. Re:Nice review, but I don't understand something. by bunratty · · Score: 1

      what the hell does I found Chapter 11 to be very useful (pun intended) mean?

      I think he meant, uh, what's that thing that spells the same backwards as forwards? A palindrome.

      --
      What a fool believes, he sees, no wise man has the power to reason away.
    7. Re:Nice review, but I don't understand something. by beardz · · Score: 2, Informative

      I may even buy the book based on the review.

      Leaving aside stuff like not for the feint of heart, which is just poor editing, what the hell does I found Chapter 11 to be very useful (pun intended) mean?

      Maybe it's the ultimate meta-pun, where there was no pun in the first place, but the author pointed out that one was intended, so one was slipstreamed into the statement.

      I think he's actually referring to Chapter 9 which is entitled "Finding Files: find, locate, slocate" hence the pun on "found".

    8. Re:Nice review, but I don't understand something. by pandrijeczko · · Score: 3, Informative

      It's a play on words. In the US, if you declare bankruptcy, you "file a Chapter 11".

      --
      Gentoo Linux - another day, another USE flag.
    9. Re:Nice review, but I don't understand something. by gardyloo · · Score: 1

      Thank you. I understand (no likey!) it now.

    10. Re:Nice review, but I don't understand something. by Anonymous Coward · · Score: 1

      It's a play on words. In the US, if you declare bankruptcy, you "file a Chapter 11".

      Actually, you file for Chapter 11 bankruptcy protection.

    11. Re:Nice review, but I don't understand something. by cain · · Score: 1

      Notlob!

    12. Re:Nice review, but I don't understand something. by mechanyx · · Score: 1

      I'm pretty sure it was a reference to this: "Chapter 11 is a chapter of the United States Bankruptcy Code, which permits reorganization under the bankruptcy laws of the United States." http://en.wikipedia.org/wiki/Chapter_11 It took me a moment as well as none of the review had anything to do with bankruptcy and not really anything to do with restructuring.

    13. Re:Nice review, but I don't understand something. by againjj · · Score: 1

      I was thinking it maybe was somehow based on the chapter title, so I looked up the book, but the chapter title was "Chapter 11: Working with Dates and Times". Maybe AC above got it right with Chapter 11 meaning bankruptcy. Or something got edited out of the review?

    14. Re:Nice review, but I don't understand something. by Jansingal · · Score: 1

      me dumb.

    15. Re:Nice review, but I don't understand something. by pandrijeczko · · Score: 1

      That's as maybe, but just because Dick Van Dyke said "Gor blimee Mary Poppins" whilst dancing round a chimney brush, that didn't make him British like me either...

      --
      Gentoo Linux - another day, another USE flag.
    16. Re:Nice review, but I don't understand something. by Duhfus · · Score: 1

      > what the hell does I found Chapter 11 to be very useful (pun intended) mean?

      May be the (poor) pun is about "Chapter 11" (http://en.wikipedia.org/wiki/Chapter_11) also referring to a bankruptcy code in the US.

    17. Re:Nice review, but I don't understand something. by gedhrel · · Score: 1

      http://oreilly.com/catalog/9780596526788/toc.html

      Perhaps the author intended to write, "...to be very timely", realised that made no sense, but left in the aside?

    18. Re:Nice review, but I don't understand something. by greysky · · Score: 2, Informative

      He FOUND chapter 11 (which is about FIND) useful. There's the pun. You had to read past the bit talking about the pun to get it.

    19. Re:Nice review, but I don't understand something. by montgomery · · Score: 1

      I think he meant going into bankruptcy.

    20. Re:Nice review, but I don't understand something. by Anonymous Coward · · Score: 0

      I may even buy the book based on the review.

      Leaving aside stuff like not for the feint of heart, which is just poor editing, what the hell does I found Chapter 11 to be very useful (pun intended) mean?

            Maybe it's the ultimate meta-pun, where there was no pun in the first place, but the author pointed out that one was intended, so one was slipstreamed into the statement.

      Chapter 11 was on find - hence the pun ;)

    21. Re:Nice review, but I don't understand something. by novapyro · · Score: 1

      Here's the pun:
      He "found" chapter 11, which apparently covers the intricacies of the "find" command to be useful.
      Found. find. That's it. All of it. Really.

    22. Re:Nice review, but I don't understand something. by Anonymous Coward · · Score: 0

      If you read later on, Ch. 11 is on the find command.

    23. Re:Nice review, but I don't understand something. by Anonymous Coward · · Score: 0

      what the hell does I found Chapter 11 to be very useful (pun intended) mean?

      Uhh... he goes on to mention that Chapter 11 taught him about the 'find' command. 'find' ... 'found' ... get it?

    24. Re:Nice review, but I don't understand something. by Anonymous Coward · · Score: 1, Informative

      Yeah, that's true and all, but the pun was the fact that he "found" Chapter 11 (the chapter on "find") to be useful -- nothing to do with bankruptcy.

    25. Re:Nice review, but I don't understand something. by Anonymous Coward · · Score: 0

      The pun was that the chapter was about the "find" command, and he "found" it helpful.

    26. Re:Nice review, but I don't understand something. by Anonymous Coward · · Score: 1, Funny

      In Soviet Russia you don't bash a book about bash, the bash book bashes you

    27. Re:Nice review, but I don't understand something. by dwiget001 · · Score: 1

      Work with dates?

      Pfft, here at Slashdot, we'd be happy just to *have* a date, let alone work with one....

    28. Re:Nice review, but I don't understand something. by Anonymous Coward · · Score: 0

      There is no pun. There would have been one if the comment had been related to bankruptcy.

    29. Re:Nice review, but I don't understand something. by Anonymous Coward · · Score: 0

      Chapter 11 is about 'find'. And he 'found' the book useful. Ohohoho.

    30. Re:Nice review, but I don't understand something. by vrmlguy · · Score: 1

      what the hell does I found Chapter 11 to be very useful (pun intended) mean?

      Judging from the next sentence, Chapter 11 is about the 'find' command. I agree, not a well-executed joke.

      --
      Nothing for 6-digit uids?
    31. Re:Nice review, but I don't understand something. by YesIAmAScript · · Score: 1

      Chapter 7 is bankruptcy (receivership).

      Chapter 11 is reorganization.

      --
      http://lkml.org/lkml/2005/8/20/95
    32. Re:Nice review, but I don't understand something. by Anonymous Coward · · Score: 0

      He FOUND chapter 11 (which is about FIND) useful. There's the pun. You had to read past the bit talking about the pun to get it.

      And then he went bankrupt?

    33. Re:Nice review, but I don't understand something. by Anonymous Coward · · Score: 0

      what the hell does I found Chapter 11 to be very useful (pun intended) mean?

      It's a pun (but not very good) because the chapter is about 'find'.

    34. Re:Nice review, but I don't understand something. by Anonymous Coward · · Score: 0

      Chapter 11 = bankruptcy.

      Now that you know, it's still not funny.

  8. Unix you say.. by The+Moof · · Score: 5, Informative

    As a BSD user (OpenBSD and FreeBSD), the only way I run into bash is to explicitly go and install it. Actually, the only place I have run into bash as a default install is on Linux.

    I run into alot more sh, ksh, csh, and tcsh.

    1. Re:Unix you say.. by Anonymous Coward · · Score: 0

      You'll find bash in cygwin and OSX too.

    2. Re:Unix you say.. by PetiePooo · · Score: 2, Informative

      As a BSD user ... I run into alot more sh, ksh, csh, and tcsh.

      Haven't they heard the news in the BSD camps? Scripting in csh is considered harmful. ;)

      In all seriousness, having scripted in both, I would consider bash more powerful than ksh, and I avoid csh/tcsh scripting for some of the (still valid) reasons listed in the legendary tome linked above.

      (Although, if performance isn't an issue, I usually attempt to stretch good old /bin/sh to its limits first. I even had it emulating expect for one task, sandwiching telnet between two scripts where the later sent signals back to the first... It worked, and kept me from having to install another package on a rigorously locked-down Solaris 8 box.)

    3. Re:Unix you say.. by morgan_greywolf · · Score: 1

      Wrong. Bash is the default shell Mac OS X, which is definitely Unix. Also on Cygwin and the Debian GNU/Hurd system, which is not Linux.

    4. Re:Unix you say.. by Anonymous Coward · · Score: 2, Informative

      ksh is far more powerful than bash. ksh93 has associative arrays, floating-point arithmetic, and coprocesses, just to name a few of the features missing in bash. In general, I've found that anything I could do in bash I could do in ksh.

    5. Re:Unix you say.. by The+Moof · · Score: 1

      Haven't they heard the news in the BSD camps? Scripting in csh is considered harmful. [faqs.org] ;)

      Think of us as typical horror movie zombies:
      Back from the dead and slow moving.

      I guess I've never had to do anything more than sh/ksh couldn't handle (or if I did, I just whipped it up in perl instead).

    6. Re:Unix you say.. by Thuktun · · Score: 1

      Also on Cygwin and the Debian GNU/Hurd system, which is not Linux.

      FYI, Cygwin is intended to be a Linux-like environment on top of Windows.

    7. Re:Unix you say.. by pjt33 · · Score: 1

      IIRC Mac OS X used to default to tcsh and switched at 10.3 or 10.4 to bash.

    8. Re:Unix you say.. by Culture20 · · Score: 1

      Indeed, I spent six years in a Solaris environment where csh and tcsh were the norm, and I only used sh in the third year there. Bash didn't get used until I spent more time in a purely linux environment.

    9. Re:Unix you say.. by Anonymous Coward · · Score: 0

      MacOS X uses bash by default, too

    10. Re:Unix you say.. by value_added · · Score: 1

      Haven't they heard the news in the BSD camps? Scripting in csh is considered harmful.

      Probably true, but then again, I've never seen anyone actually doing so. I'd suggest that a more widespread problem is the assumption that Linux represents the entire *nix world, that scripts should be written in bash, and bash-isms are something to be encouraged.

      In the BSD world, scripts are invariably written in /bin/sh. Platform independence (to the extent possible), consistency and speed are not something to be sneezed at.

      Bash and friends are, generally, best reserved for interactive use. So while it's true that the default shell on BSD is csh, it's fairly common to see bash installed. On my own systems, I compile bash statically but despite that long held habit, I've never chosen to rely on it or write scripts that did the same.

    11. Re:Unix you say.. by tooth · · Score: 1

      Same with HPUX

  9. Bash cookbook? by mea37 · · Score: 4, Funny

    Well, ok... Cookbook sucks!

    Oh, did I parse that wrong?

    1. Re:Bash cookbook? by morgan_greywolf · · Score: 1

      ...And this is why more parsers are written in Perl these days. /me ducks.

  10. Bash this: by Anonymous Coward · · Score: 0

    :(){ :|:& };:

    1. Re:Bash this: by Cartan · · Score: 1

      You, Sir, are an asshole ;-)

      --
      "Don't ask for whom the ^G tolls."
  11. It's for people like me. by khasim · · Score: 5, Interesting

    Who already own "sed and awk" and buy a book that is supposedly about Bash scripting only to find out that the advanced section replicates what is in the sed and awk book. Which is very annoying.

    Not that it's a bad book. I just believe that it should have been more focused on Bash only scripting.

    If you want to learn about sed and awk, buy the sed and awk book. If you want to learn Bash scripting, there are a LOT of more useful sites online.

    1. Re:It's for people like me. by CastrTroy · · Score: 2, Insightful

      Maybe we should all have to buy different books on grep too. Why not separate books on dd, ls, df, free, etc? sed and awk are a very integral part of bashscripting. You can't talk about bash without talking about sed and awk. Same way you can't talk about Perl without talking about regular expressions. Well, on second thought, you could, but you'd be leaving out a huge part reason for using Perl in the first place.

      --

      Anthropic principle: We see the universe the way it is because if it were different we would not be here to see it.
    2. Re:It's for people like me. by MikeBabcock · · Score: 1

      That just shows ignorance of how much power exists within bash without using sed or awk. It also shows a lack of understanding of how powerful each sed and awk are as individual programs (or language, in awk's case).

      You can write some substantial software in awk, and in bash, or in a combination of both, or using sed.

      Of course, mentioning 'make' in a book on C programming makes sense, but not realizing how powerful make is is probably a result of how people associate it with programming only.

      (example: I have a Makefile in /etc/samba to build my smb.conf from an smb-master.conf file after checking it for errors and stripping out comments)

      --
      - Michael T. Babcock (Yes, I blog)
    3. Re:It's for people like me. by CastrTroy · · Score: 5, Insightful

      I'm not sure where our opinions differ. sed and awk are both extremely powerful. bash is extremely powerful. One of the things that makes bash powerful is the existence of sed and awk. sed and awk don't require bash, and bash doesn't require sed and awk. Yet if you write a book on using bash, and leave out sed and awk, you would be doing your readers a great injustice.

      --

      Anthropic principle: We see the universe the way it is because if it were different we would not be here to see it.
    4. Re:It's for people like me. by computational+super · · Score: 2, Funny
      separate books on dd, ls, df, free, etc?

      Dude, seriously? Where? Cool!

      Oh, wait, you were being sarcastic. Dammit. Don't get my hopes up like that.

      --
      Proud neuron in the Slashdot hivemind since 2002.
    5. Re:It's for people like me. by pjt33 · · Score: 1

      If you want to learn Bash, read the man page. I once spent hours tidying up an HTML version of it, and I learnt a lot in the process.

    6. Re:It's for people like me. by greenguy · · Score: 4, Funny

      A good analogy is like a car.

      No. A good analogy is like a metaphor.

      --
      What if I do the same thing, and I do get different results?
    7. Re:It's for people like me. by CastrTroy · · Score: 1

      I think you meant,

      A good analogy is a metaphor.

      or

      A good analogy is like a simile.

      --

      Anthropic principle: We see the universe the way it is because if it were different we would not be here to see it.
    8. Re:It's for people like me. by Anonymous Coward · · Score: 0

      Unfortunately, you used a simile.

  12. Largest BASH script? by Anonymous Coward · · Score: 1, Interesting

    I wonder what is the largest BASH script ever made?

    7000 lines of BASH code:
    http://ra.vendomar.ee/~ivo/finstall

    1. Re:Largest BASH script? by bjourne · · Score: 1

      That's nothing. The configure scripts autoconf generates are regularly up to 50k in size. Although they are SHell scripts and should work in any shell.

  13. Shell as a scripting language... by Tetsujin · · Score: 1

    Now, here's what I'd like to know...

    Are you serious here, showing that both shells support useful features, or are you being facetious, showing that both shells are merely acceptable stepping-stones to run Perl code?

    I love CLIs but my feeling on most of them is that they're more than a little archaic - the lack of any non-trivial datatypes (and particularly the lack of support for passing structured data or live objects between shell processes) makes it needlessly difficult to get things done - I believe that is one of the major reasons people script with scripting languages these days instead of shells...

    --
    Bow-ties are cool.
    1. Re:Shell as a scripting language... by retchdog · · Score: 1

      For this reason, I wish that things like the zoidberg shell would hurry up & mature. (Yeah, yeah, I would work on it myself except I would probably be about as useful as the namesake Dr. Zoidberg is as a doctor.)

      "Ask not what you can do for your shell, ask what your shell can do for you!"

      --
      "They were pure niggers." – Noam Chomsky
    2. Re:Shell as a scripting language... by Anonymous Coward · · Score: 0

      Most data translation projects don't need advanced data structures to get the work done. This common misconception is responsible for a great deal of the software project failures over the last few decades.

    3. Re:Shell as a scripting language... by Anonymous Coward · · Score: 0

      And a great deal of software projects.

    4. Re:Shell as a scripting language... by CastrTroy · · Score: 4, Insightful

      The lack of structured data and live objects is a feature, not a bug. The fact that everything is a string, and that everything can be piped between all the different commands means that you can string together commands in new and exciting ways that nobody ever thought was possible. Making all the commands pass around different types of objects means that all the other commands have to be aware of all these other datatypes, and have to know how to handle them. If you want something with objects and structured data in the shell, then there's MS PowerShell. But maybe there's a reason it hasn't caught on yet.

      --

      Anthropic principle: We see the universe the way it is because if it were different we would not be here to see it.
    5. Re:Shell as a scripting language... by Tetsujin · · Score: 1

      Most data translation projects don't need advanced data structures to get the work done. This common misconception is responsible for a great deal of the software project failures over the last few decades.

      I'm just talking about basic data structures here - support for anything beyond strings or text streams. Shell programming has become mired in translation steps. Scripting languages let you avoid all that because the language provides data structures and objects, as well as a reasonable set of baseline data types, which modules written in the language can work with.

      Some shells support some data structures and containers, but I think Powershell is the only one right now that can actually pass these between processes...

      --
      Bow-ties are cool.
    6. Re:Shell as a scripting language... by Unordained · · Score: 3, Informative

      From what I've seen (not used it) the new Windows PowerShell (Monad) is designed around "piping" data between apps that actually exchange .Net objects, including lists, maps, etc. of objects -- rather than character streams. There seem to be generic commands that provide sql-like "select / where" filtering clauses, etc., too. You might explore that, see if it fits your needs. It looks awfully verbose to me though, I'd have to find a way to set aliases for most everything. Just a thought.

    7. Re:Shell as a scripting language... by colmore · · Score: 1

      Yeah, old-school bash is about as fun as doing trivial tasks in C. And I love C. But still...

      I use bash and a little folder in my $PATH as a more robust solution to alias-ing.

      But for anything over 1 or 2 lines, calling shell utilities from Ruby is about a hundred million times easier.

      I can't keep that archaic syntax in my head for more than a day at a time.

      --
      In Capitalist America, bank robs you!
    8. Re:Shell as a scripting language... by Tetsujin · · Score: 4, Interesting

      The lack of structured data and live objects is a feature, not a bug. The fact that everything is a string, and that everything can be piped between all the different commands means that you can string together commands in new and exciting ways that nobody ever thought was possible. Making all the commands pass around different types of objects means that all the other commands have to be aware of all these other datatypes, and have to know how to handle them.

      This is true of textual data as well - you're simply glossing over the complexity of serializing and re-parsing any non-trivial data structure in textual form... You've ignored the fact that for any two tools to work together, their assumptions about the structure with which data is encoded over the stream have to match.

      See, if your text-encoded data is simple enough that you can simply choose a character as a field delimiter and another as a record separator, it's easy to split your data into individual records and fields again. It gets a little harder if you want to provide for the possibility that your records may actually contain the delimiter characters (then you're into parsing - at least enough parsing to distinguish between an escaped character and an unescaped one) Setting up the format so you can really encapsulate anything - that reaches the point where it's worth having a tool whose only job is interfacing with this format...

      The problem here is that normally when you want to interpret some encoded form of a piece of data, you first translate it into something that's easier to work with. But in BASH (and most CLI shells, I believe) there is no "more convenient form" to which you can readily translate any moderately complex structure. (Consider, for instance, how you would implement an XML parser for Bash - as an external command it simply wouldn't work... it'd have to be done as a Bash plug-in module, and even then its capabilities would be limited. And then suppose you want to filter the parsed data and pass it to another process? You've got to re-encode it, and then the next process has to know how to decode this encoding (probably still XML) as well...

      I contend that the "encode everything as a string" mentality was an asset, due to computer limitations in the time period in which the convention started - but these days I think it's pretty limiting.

      If you want something with objects and structured data in the shell, then there's MS PowerShell. But maybe there's a reason it hasn't caught on yet.

      I think Powershell has been progressing (in terms of popularity, I mean) quite satisfactorily... The reason it hasn't caught on with me, however, is 'cause I want a Unix solution (that is, runs on Unix, and fairly Unix-styled), not a Windows one - and while I agree with the logic behind some of their design decisions (like the verb-noun convention for command names) I don't like the consequences (the language is much too verbose for my tastes...)

      I think it's a step in the right direction but not quite what I'm looking for.

      Assuming Powershell hasn't been embraced and taking that as a sign that one particular facet of its design was a bad idea is pretty laughable. Any new tool takes time to be adopted - and Powershell is a tool for a fairly small niche - CLI users on Windows.

      --
      Bow-ties are cool.
    9. Re:Shell as a scripting language... by laejoh · · Score: 1

      Hey, I agree. I love CLIs and all the little tools but if they don't 'cut' it...

      Here's what I do when I get stuck in awk:

      awk 'BEGIN { system("ls;perl -e \"print \"Hello World!\"\"") }'

    10. Re:Shell as a scripting language... by Tetsujin · · Score: 1

      From what I've seen (not used it) the new Windows PowerShell (Monad) is designed around "piping" data between apps that actually exchange .Net objects, including lists, maps, etc. of objects -- rather than character streams. There seem to be generic commands that provide sql-like "select / where" filtering clauses, etc., too. You might explore that, see if it fits your needs. It looks awfully verbose to me though, I'd have to find a way to set aliases for most everything. Just a thought.

      Yeah, I learned about Monad a few years back, and have tried Powershell, briefly anyway - it's definitely interesting but various things about it don't really suit my tastes. I'm trying to come up with something that does.

      --
      Bow-ties are cool.
    11. Re:Shell as a scripting language... by laejoh · · Score: 1

      Ooooops, I meant

      awk 'BEGIN { system("perl -e \"print 1+1 \" ") }'

    12. Re:Shell as a scripting language... by hachete · · Score: 3, Funny

      What are these "datastructures" you speak of?

      --
      Patriotism is a virtue of the vicious
    13. Re:Shell as a scripting language... by hal9000(jr) · · Score: 2, Insightful

      You've ignored the fact that for any two tools to work together, their assumptions about the structure with which data is encoded over the stream have to match.

      Dude, it is upto the programmer to format the data properly, including any escaping when piping strings from one proggie to another.

      Shell scripts aren't supposed to replace more robust programming languages. I think it silly to want to parse XML via shell scripts, BUT, a shell script could pull useful data from an XML file.

      So let me state the obvious, find the right tool for the job rather than thinking everyones tries to shoe horn everything into the same tool.

    14. Re:Shell as a scripting language... by algae · · Score: 1

      It's where you use a delimiter to divide elements in a string for easy parsing ;)

      --
      Causation can cause correlation
    15. Re:Shell as a scripting language... by Anonymous Coward · · Score: 0

      I contend that the "encode everything as a string" mentality was an asset, due to computer limitations in the time period in which the convention started

      Encoding everything as a string was done due to human limitations, not computer limitations. Computer limitations of the time were used to argue against this form of simplification, although in many cases these arguments were unconvincing(much like the similar arguments of today).

      but these days I think it's pretty limiting.

      Limitations are often an asset. It was limiting back then, and purposefully so.

      Consider, for instance, how you would implement an XML parser for Bash - as an external command it simply wouldn't work

      Yes, it does work. I use tools like xsltproc, xslto, and tidy to work with HTML and XML documents from the command line and in shell scripts all of the time.

      suppose you want to filter the parsed data and pass it to another process? You've got to re-encode it

      No, not necessarily.

    16. Re:Shell as a scripting language... by Anonymous Coward · · Score: 0

      Monad = Gonads.

    17. Re:Shell as a scripting language... by dkixk · · Score: 2, Interesting

      For this reason, I wish that things like the zoidberg shell would hurry up & mature. (Yeah, yeah, I would work on it myself except I would probably be about as useful as the namesake Dr. Zoidberg is as a doctor.)

      "Ask not what you can do for your shell, ask what your shell can do for you!"

      I've always avoided shell scripting as much as possible. Here is an example of the kind of thing that drives me nuts about shell.


      $ touch "file 1" "file 2" foo bar
      $ for i in *; do touch "$i.titles"; done
      $ ls
      bar bar.titles file 1 file 1.titles file 2 file 2.titles foo foo.titles
      $ grep -l beer `find . -name \*.titles -prune -o -print`
      grep: ./file: No such file or directory
      grep: 2: No such file or directory
      grep: ./file: No such file or directory
      grep: 1: No such file or directory
      $ find . -name \*.titles -print -o -exec grep -l beer {} /dev/null \;
      ./file 2.titles
      ./bar.titles
      ./file 1.titles
      ./foo.titles

      One needs to remember to quote the touch used in the for loop because of the spaces in some of the names. However, when using find with backticks, the spaces in the names become part of the delimiter of the list of file names. An alternative version of the find command works, but only if one remembers to use the later instead of the former.

      The idea behind Zoidberg is not new or unique. From the copyright for Zoidberg, it seems that it was first released in 2003. However, scsch, to Scheme what Zoidberg is to Perl, seems to have been around at least as long as 1994. And one should remember Genera, an operating system in which everything was Lisp from the ground up, and dates back to the early 80s. A Lisp listener was a "shell", from what I can tell, having only a second hand familiarity with it.

      But I personally like having the combination of Emacs and inferior processes, especially SLIME. With it, I'm able to switch between Emacs GUI, Emacs lisp commands, Emacs key commands, Common Lisp, or even just running a standard bash shell all from within one environment. So I can use the shell command approach, returning one big string as a list of files, with the same problem of file names with spaces looking like separate elements of the list, Emacs lisp code, or even Common Lisp code.


      LAMP-USER> !$(find /home/dkick/tmp/duff -name *\.titles -prune -o -print)
      "/home/dkick/tmp/duff
      /home/dkick/tmp/duff/bar
      /home/dkick/tmp/duff/foo
      /home/dkick/tmp/duff/file 2
      /home/dkick/tmp/duff/file 1
      "
      #<SB-IMPL::PROCESS :EXITED 0>
      LAMP-USER> (remove "titles" (list-directory "/home/dkick/tmp/duff/") :test #'equal :key #'pathname-type)
      (#P"/home/dkick/tmp/duff/bar" #P"/home/dkick/tmp/duff/file 1"
      #P"/home/dkick/tmp/duff/file 2" #P"/home/dkick/tmp/duff/foo")
      LAMP-USER>

    18. Re:Shell as a scripting language... by sciurus0 · · Score: 3, Informative
      While you're waiting on Zoidberg, here are a few projects you should check out:
      1. Rush, a ruby shell. Rush strikes me as a very cool project. This slideshow is a good introduction.
      2. iPython with the "sh" profile. About halfway into this article they discuss it.
      3. Hotwire, an "object-oriented hypershell"
    19. Re:Shell as a scripting language... by gullevek · · Score: 1

      I agree. Bash is nice for very small things, but anything that does more than just tiny tiny baby steps it's way smarter to user perl/ruby/python.

      --
      "Freiheit ist immer auch die Freiheit des Andersdenkenden" - Rosa Luxemburg, 1871 - 1919
    20. Re:Shell as a scripting language... by poopdeville · · Score: 1

      Don't forget Squeak either.

      --
      After all, I am strangely colored.
    21. Re:Shell as a scripting language... by BrainInAJar · · Score: 1

      Sounds like a problem with bash more than anything

      ksh93 can parse XML plenty fine

    22. Re:Shell as a scripting language... by DSmith1974 · · Score: 1

      I don't like the consequences (the language is much too verbose for my tastes...)

      Powershell is an elastic language, so you can use the fully verbose verb-noun convention, the short-cuts or any unambiguous abbreviation. The following one-liners are identical:

      $items | for-each{ $_ | get-members }

      $items |%{$_ |gm}

      --
      It is not immoral to create the human species - with or without ceremony, Samuel Clemens.
    23. Re:Shell as a scripting language... by DSmith1974 · · Score: 1, Informative

      You might explore that, see if it fits your needs. It looks awfully verbose to me though

      You can set your own aliases in the $profile script but you don't need to; Powershell is already an elastic language

      These two one-liners are functionally identical:

      $items | foreach { $_ | get-members }

      $items |%{$_ |gm}

      --
      It is not immoral to create the human species - with or without ceremony, Samuel Clemens.
    24. Re:Shell as a scripting language... by profplump · · Score: 1

      Unless the things you're doing involve launching lots of programs -- it's a lot easier to redirect file descriptors and launch programs in bash than perl. You get a lot more options in perl, but there's a lot more code required too.

    25. Re:Shell as a scripting language... by Monsieur_F · · Score: 1

      You can use IFS for this problem :
      IFS=$'\n'; grep -l beer `find . -name \*.titles -prune -o -print`

      --
      McCartney fans pay bus tickets. [...] Lennon fans too, with discretion.
    26. Re:Shell as a scripting language... by Tetsujin · · Score: 1

      Sounds like a problem with bash more than anything

      ksh93 can parse XML plenty fine

      And that's great. But I'm not talking just about the ability to parse XML - I'm talking about the ability to extend the shell to handle a problem like parsing XML - and what you can do with that data once the parsing is done.

      In scripting languages like Perl or Python - you have datatypes supported by the language, recognized by all modules written for that language - so you've got a lot of power in terms of what a newly-added module can do, and how it can interact with other modules. But then when you want to communicate with another process, the problem of data exchange becomes rather more complicated... The same is generally true in shells as well - the shell language itself may have a somewhat reasonable set of datatypes (bash has arrays at least - IIRC another shell, ksh maybe, provides associative arrays) but when it comes to passing this structured data elsewhere, you're pretty much stuck.

      Given that the whole idea of the shell is supposed to be about stringing together little tools to do different parts of a bigger job, this stifled communication is, as far as I'm concerned, a big problem. You only get the full programming capabilities out of your shell when you're working with different shell modules running in the same shell. Code running in two different shell instances, or code interacting with another process has to deal with the "minimal assumptions" of shell data streaming and process invocation.

      --
      Bow-ties are cool.
    27. Re:Shell as a scripting language... by Tetsujin · · Score: 1

      You've ignored the fact that for any two tools to work together, their assumptions about the structure with which data is encoded over the stream have to match.

      Dude, it is up to the programmer to format the data properly, including any escaping when piping strings from one proggie to another.

      Yes, that's precisely my complaint. Even the simplest exchange of structured data between two processes on a typical shell requires this kind of attention.

      Shell scripts aren't supposed to replace more robust programming languages.

      Why not? The way I see it, half these "more robust programming languages" used by Unix users were introduced to get around limitations of the shell. (Perl being the prime example - though calling it "robust" is arguable...)

      I think it silly to want to parse XML via shell scripts, BUT, a shell script could pull useful data from an XML file.

      Pulling data out of an XML file means parsing XML data.

      My point was not to say that bash can't parse XML or that it should - the point is that it's not one well suited for handling problems of that complexity. You need shell-level support either for objects or streamable data structures so your XML-wrangling tools - so that the XML parser could either be interrogated (as an object) about the XML contents or dump out the contents (as a data structure).

      So let me state the obvious, find the right tool for the job rather than thinking everyones tries to shoe horn everything into the same tool.

      The idea of a Unix shell is to support different tools working together: small, single-purpose tools chained together to tackle larger problems. In that capacity it is failing - the complexity of passing data between these "small tools" makes it needlessly difficult to implement a module to do a job as a shell program on the PATH. So to avoid all that hassle people write Perl or Python modules instead.

      --
      Bow-ties are cool.
    28. Re:Shell as a scripting language... by Tetsujin · · Score: 1

      I contend that the "encode everything as a string" mentality was an asset, due to computer limitations in the time period in which the convention started

      Encoding everything as a string was done due to human limitations, not computer limitations. Computer limitations of the time were used to argue against this form of simplification, although in many cases these arguments were unconvincing(much like the similar arguments of today).

      The computer limitations at the time required a particular level of compromise between lack of complexity in the solution and space-and-time efficiency. But, while the text formats were bulky and inefficient, the tools that processed them could be relatively simple - requiring little more than the standard C library.

      Nowadays, we don't need that level of space-efficiency on the code being run. For instance, in the 1970s and 1980s you could safely assume a Unix system would have the standard C library and some reasonably standard system calls. Nowadays, it's a safe bet a Unix system has at least on XML lib. If XML or another similarly capable (and hopefully more efficient) format were taken as a shell-level assumption for process-to-process exchange, then writing the tools that run in the shell would be no more complex, and writing shell code to translate one process's XML output to another process's XML input would be simpler than the equivalent translation done today (with the first process's ad-hoc text output format and the second process's ad-hoc text input format...) If the shell at least has a pretty good idea of the structure of the data that's likely to come over the stream, then it can provide support in the language to help you translate data.

      "Unconvincing arguments" depend on who needs convincing - and who's doing the arguing. Sadly, I am not as good at debate as I should be, if I want to advocate this kind of change. This is part of the reason I take up this argument from time to time, and debate it with anyone who's willing - to fill gaps in my knowledge and to learn how to argue my case better.

      but these days I think it's pretty limiting.

      Limitations are often an asset. It was limiting back then, and purposefully so.

      Limiting the conceptual complexity of your interface is an asset. Limiting the programmatic complexity of coding for your environment is an asset. The problem is that any kind of limitation is also a trade-off in terms of power.

      The Unix shell makes minimal assumptions about the format of data that goes over pipes. This is an asset in a sense - it is flexible and it is simple to implement. Where this limitation becomes a problem is in the burden it places on the people using the shell. The concept behind Unix Shell as a scripting language was to have a large number of small tools, each fairly simple in concept and limited in scope - and to have these tools work together. The problem is that when you make no assumptions about what goes over the stream, then every tool incorporating a serialize/deserialize step must come up with a serialization format - usually these don't match because the programmers each came up with a format that worked for their own tool. The shell can't provide much in the way of help translating between formats because no assumptions are made even about what kind of formats are even likely to go over the stream.

      Making XML (or a more efficient format with similar capabilities) an assumption in the Unix Shell and all standard Unix tools would be one solution - the reason I favor a binary format rather than XML (or, perhaps, a binary encoding of XML) for this job is because text-encoded XML doesn't really gain the user anything. In the processing steps the user won't see XML, and when viewing output, you don't want a raw XML dump anyway - as lo

      --
      Bow-ties are cool.
    29. Re:Shell as a scripting language... by Anonymous Coward · · Score: 0

      I am still waiting for Oyster, a shell with a little Perl in it.

    30. Re:Shell as a scripting language... by dkixk · · Score: 1

      I said: "Doctor, I've broken my arm in several places."

      Doctor: "Then don't go to those places."


      $ ls
      bar file 1 file 2 foo homer?like?duff
      bar.titles file 1.titles file 2.titles foo.titles homer?like?duff.titles

      $ IFS=$'\n'; grep -l beer `find . -name \*.titles -prune -o -print`
      duffmer

      As opposed to


      LAMP-USER> !$(find /home/dkick/tmp/duff -name *\.titles -prune -o -print)
      "/home/dkick/tmp/duff
      /home/dkick/tmp/duff/bar
      /home/dkick/tmp/duff/foo
      /home/dkick/tmp/duff/file 2
      /home/dkick/tmp/duff/homer^Mlike^Mduff
      /home/dkick/tmp/duff/file 1
      "
      #<SB-IMPL::PROCESS :EXITED 0>
      LAMP-USER> (remove "titles" (list-directory "/home/dkick/tmp/duff/") :test #'equal :key #'pathname-type)
      (#P"/home/dkick/tmp/duff/bar" #P"/home/dkick/tmp/duff/file 1"
      #P"/home/dkick/tmp/duff/file 2" #P"/home/dkick/tmp/duff/foo"
      #P"/home/dkick/tmp/duff/homer^Mlike^Mduff")
      LAMP-USER>

  14. Bash has been my favorite for 12 years by Ex-Linux-Fanboy · · Score: 4, Informative
    Bash has been my favorite interactive shell for 12 years now. Basically, *NIX command shells, which in the 1980s had a lot of interesting ideas presented (csh, tcsh, ksh, etc.), have basically settled down. The only shells I have seen in use on modern *NIX systems (read Linux and the odd BSD) is Bash and Ash. Ash has had a resurgence in popularity lately because a version of it is part of Busybox (along with a tiny implementation of awk).

    Bash takes Bourne Shell scripting (which was always more powerful than Csh scripting), and combines it with Csh's and Tcsh's best interactive features (! expansion, arrow history, tab completion, etc.).

    The last time I saw people try to have a different paradigm with *NIX shells was with the 'rc' and 'es' shells of the 1990s, which was an attempt to introduce functional programming to the shell. Both shells stopped being actively developed before they were full featured (they never had job control, for example).

    More recently, there is a new shell out there called the 'fish' shell, which I tried and didn't like. I don't like its requirement to have everything in a bunch of colors; a true *NIX shell, in my opinion, should not try and make everything colorful (I also despise ls with colors).

    Looks like ksh finally was open sourced, but by then Bash had become the standard shell you're guaranteed to have in just about any Linux distribution (exceptions being tiny distributions which use Busybox for everything).

    More information, of course, is on the Wikipedia..

    1. Re:Bash has been my favorite for 12 years by Anonymous Coward · · Score: 0

      The only shells I have seen in use on modern *NIX systems (read Linux and the odd BSD) is Bash and Ash.

      Really? Which BSD derivatives ship with Bash or Ash? The most popular once sure don't. Although Bash is ubiquitous on Linux, other operating systems often use the Bourne shell for scripting and a C-like shell for interactive use.

    2. Re:Bash has been my favorite for 12 years by Black-Man · · Score: 1

      In my experience, any ksh script would run under bash. It was my impression that bash was a catch-all, taking the better ideas from Korn and Bourne.

    3. Re:Bash has been my favorite for 12 years by thogard · · Score: 1

      One key issue is that systems on boot may not have access to all the libraries that make bash a nice human interface. A core system needs a shell that uses no shared libraries at all and does only simple things to start up programs (like a real shell)... If all that can be kept in nice clean text files that include #!/bin/sh to indicate that they won't be doing anything complicated, then it makes it much easier for developers. While I love to use bash, I wouldn't ever consider if for the rc scripts or single user mode if I had an option.

    4. Re:Bash has been my favorite for 12 years by morgan_greywolf · · Score: 1

      BSD boxes don't use bash by default. If you want functional programming in the shell, get yourself a LISP machine. Or Emacs. ;)

    5. Re:Bash has been my favorite for 12 years by Jason+Quinn · · Score: 1

      Good comment. From my perspective however, the two real shells are bash and tcsh. I've been using bash for the last year or so simply because I got tired of changing the default shell in modern distros. But I prefer tcsh for scripting because it is much cleaner syntax-wise even if bash has a few more powerful features. I honestly never even heard of the Ash shell. I'll have to check it out but I just learned it doesn't have tab-completion and I love that feature.

    6. Re:Bash has been my favorite for 12 years by Ex-Linux-Fanboy · · Score: 1

      Ash is a small shell that is basically yet another attempt to make an open-source POSIX-compliant version of /bin/sh. It's nice because it's small; the runtime is about 50k, and it has been ported to Busybox, which makes it a nice "tiny Bash". It's /bin/sh on some BSD systems and on Ubuntu. The Wikipedia knows all, of course.

      It's a good way to make sure scripts don't have Bash-isms.

      - Sam

    7. Re:Bash has been my favorite for 12 years by Anonymous Coward · · Score: 0

      I used bash until I discovered zsh in 1997. Has bash caught up in features?

      The most notable ones that hooked me were tab-completion for history and wildcard expansion. There are also quite a few minor ones like supporting ksh-style history in addition to csh-style.

      Note that most non-Linux systems that include bash also include zsh, so it isn't exactly obscure. I'm surprised you fail to mention it.

  15. Re-usable libraries by john_anderson_ii · · Score: 2, Insightful

    Bash is just plain awesome, I'm always trying to find ways to push it even further, I'm checking to see if this book is on safari right now.

    I do a lot of work in bash. I'm a Linux administrator by trade, so I think in bash all day long. For my company I've developed a set of bash libraries that we call the BPE. These libraries implement a hashmap, stack, linked list, MySQL API, SQLite API and all sorts of other useful things that one doesn't want to re-invent for every script. I'm in the process of writing man pages for the several libraries right now, and I think I'll sourceforge the project when the mans are complete. It's great to be able to begin a new script when a hashmap might be useful, and be able to do something like:

    $USE_BPE
    use "hashmap"

    hm_create "myMap"
    hm_set "myMap" "key" "value"
    value="$(hm_lookup "myMap" "key")"
    echo "$value"

    In short, if organized correctly, bash can be used where a senior sysadmin would normally reach for perl or python. This is often helpful when your juniors have a good grasp of bash, but aren't very strong in other languages.

    --
    Be Safe! Sleep with a Marine. Semper Fi!
    1. Re:Re-usable libraries by farmer11 · · Score: 1

      I've developed a set of bash libraries that we call the BPE. These libraries implement a hashmap, stack, linked list, MySQL API, SQLite API and all sorts of other useful things that one doesn't want to re-invent for every script.

      Speaking of useful things that one doesn't want to re-invent... But seriously, when you're implementing stuff like hashmap you're either creating a new programming language or it's time to select a better tool.

    2. Re:Re-usable libraries by john_anderson_ii · · Score: 1

      Not when your hobby is doing fun/weird things with bash.

      --
      Be Safe! Sleep with a Marine. Semper Fi!
    3. Re:Re-usable libraries by Sancho · · Score: 2, Insightful

      That sounds pretty neat and all, but wouldn't you be better served training people on a language which has these constructs built in? The juniors are still having to learn new programming syntax--only instead of learning Perl, they're learning something that's not used anywhere else in the world.

      Is this a way of enforcing loyalty? :)

    4. Re:Re-usable libraries by john_anderson_ii · · Score: 1

      Why would they need to lean new syntax? We still use bash syntax when writing BPE scripts. They need only to learn the names, arguments, and returns of the function calls. Just like they would for any software product. It's not like the BPE implementation is restricting them from learning perl or python or anything else

      Doing advanced things in bash is a personal hobby mine, and if it proves useful to other admins and the company as well, than that's just a bonus.

      --
      Be Safe! Sleep with a Marine. Semper Fi!
    5. Re:Re-usable libraries by Abcd1234 · · Score: 2, Informative

      In short, if organized correctly, bash can be used where a senior sysadmin would normally reach for perl or python. This is often helpful when your juniors have a good grasp of bash, but aren't very strong in other languages.

      You mean it makes it possible to use the wrong tool for the job, in order to avoid a little training.

      No offense, but that's a *really* terrible idea.

    6. Re:Re-usable libraries by Sancho · · Score: 1

      They're learning the syntax of your library. They could be learning the syntax of Perl. They could learn both, but they're duplicating effort then.

      I'm not knocking making the libraries itself, but it just seems like time spent learning your library (for the job) could be spent learning something which is more universally used.

    7. Re:Re-usable libraries by jalefkowit · · Score: 1

      Doing advanced things in bash is a personal hobby mine, and if it proves useful to other admins and the company as well, than that's just a bonus.

      Unless you leave or are hit by a bus, and then some poor slob has to come in and reverse-engineer all your cleverness to figure out how to keep your company's systems working.

      If it's a personal hobby of yours, tinker with it at home. Don't be forcing everybody you work with to take up your hobby too.

    8. Re:Re-usable libraries by afabbro · · Score: 1

      ...particularly because they will likely move to another job someday and these libraries will no longer be available.

      Right tool for the right job is a better skill to learn.

      --
      Advice: on VPS providers
    9. Re:Re-usable libraries by umghhh · · Score: 1

      I just had to do some small script job today and with help of power tools book (scripting is not my job really) I managed quite nicely.

      I recalled then the hell I had to go through when (years ago) I worked for another customer that had windouze system mostly and the problems we had with writing some sort of consistent (over different Os and office versions) scripts to do basic stuff.

      I recalled also work for another big customer that actually built its own test suite as shell script language/library organized around drivers that interfaced the produced software packages.

      There is really no comparison. *n*x systems that had usefull features were available decades ago. What a shame redmont did not have to and did not take notice,

    10. Re:Re-usable libraries by Sancho · · Score: 1

      That's where I was coming from in some of my replies to this guy. It sounds like a really neat little hack, and I'd love to see the implementation, but using those libraries instead of learning Perl seems more like a bandage.

      I understand the motivation. Presumably, these junior admins know bash, and bash has shortcomings, so if you can fix those shortcomings, there's a small gain in efficiency. It's just that in the long run, for both the company and the individual, it would probably be worth learning Perl.

  16. fnashre0n smilleee!!!! by Anonymous Coward · · Score: 0

    plig smorlen analis

  17. Power scripters don't limit shells by al0ha · · Score: 1, Interesting

    Bash is cool and I suppose this book is decent, though I've found UNIX for Programmers and Users to be the most useful as it covers Bash, SH and KSH. KSH rocks!

    --
    Did you ever wake up in the morning, with a Zombie Woof behind your eyes? -- FZ
  18. Another morbidly obese "programming" book by Animats · · Score: 2, Insightful

    598 pages for a book on a shell? Oink!

    A little plastic cheat sheet would be far more useful. The important thing is to get the basic ideas and the syntax. That requires a small, tightly written book. In an oinker of a book, the concepts get lost in the verbiage.

    1. Re:Another morbidly obese "programming" book by MikeBabcock · · Score: 1

      It could be argued that Bash has more language features than many programming languages.

      Bash is a huge and very powerful system for both shell work and programming work. The programmable tab-completion being one of my favourites, spell checking is fun too, although I still prefer tcsh's syntax.

      --
      - Michael T. Babcock (Yes, I blog)
    2. Re:Another morbidly obese "programming" book by HikingStick · · Score: 1

      You're forgetting that not all people share your preferred learning style. Some will thrive off the cheat sheet. Some need to review cocepts and other abstract pieces of information. Those who are auditory learners, like me, tend to subvocalize everything we read, so the so-called "wordy" texts are often the ones that are easiest for me to digest (assuming they are written in a conversational style).

      If a cheat sheet is your m.o., then I'd venture a gues that your a kinesthetic (someone who learns best in a hands-on environment). Most people have a primary style preference, but also function well in one or more other methods of learning. There are some, however, who are only able to "get it" when they learn in accordance to their primary style.

      --
      I use irony whenever I can, but my shirts are still wrinkled...
  19. Review of BASH COOKBOOK by ylikone · · Score: 2, Interesting
    This book covers the GNU Bourne Again Shell, which is a member of the Bourne family of shells that includes the original Bourne shell sh, the Korn shell ksh, and the Public Domain Korn Shell pdksh. This book is for anyone who uses a Unix or Linux system, as well as system administrators who may use several systems on any given day. Thus, there are solutions and useful sections for all levels of users including newcomers. This book is full of recipes for creating scripts and interacting with the shell that will allow you to greatly increase your productivity.

    Chapter 1, "Beginning bash" covers what a shell is, why you should care about it, and then the basics of bash including how you get it on your system. The next five chapters are on the basics that you would need when working with any shell - standard I/O, command execution, shell variables, and shell logic and arithmetic. Next there are two chapters on "Intermediate Shell Tools". These chapters' recipes use some utilities that are not part of the shell, but which are so useful that it is hard to imagine using the shell without them, such as "sort" and "grep", for example. Chapter nine features recipes that allow you to find files by case, date, type, size, etc. Chapter 10, "Additional Features for Scripting" has much to do with code reuse, which is something you find even in scripting. Chapter 11, "Working with Dates and Times", seems like it would be very simple, but it's not. This chapter helps you get through the complexities of dealing with different formats for displaying the time and date and converting between various date formats.

    Chapter 12, "End-User Tasks As Shell Scripts", shows you a few larger though not large examples of scripts. They are meant to give you useful, real world examples of actual uses of shell scripts beyond just system administration tasks. Chapter 13, "Parsing and Similar Tasks", is about tasks that will be familiar to programmers. It's not necessarily full of more advanced scripts than the other recipes in the book, but if you are not a programmer, these tasks might seem obscure or irrelevant to your use of bash. Topics covered include parsing HTML, setting up a database with MySQL, and both trimming and compressing whitespace. Chapter 14 is on dealing with the security of your shell scripts. Chapters 15 through 19 finish up the book starting with a chapter on advanced scripting that focuses on script portability. Chapter 16 is related to the previous chapter on portability and is concerned with configuring and customizing your bash environment. Chapter 17 is about miscellaneous items that didn't fit well into any other chapter. The subjects include capturing file metadata for recovery, sharing and logging sessions, and unzipping many ZIP files at once. Chapter 18 deals with shortcuts aimed at the limiting factor of many uses of bash - the typing speed of the user and shortcuts that cut down on the amount of typing necessary. The final chapter in the book, "Tips and Traps", deals with the common mistakes that bash users make.

    All in all this is a very handy reference for a vast number of the tasks that you'll come across when scripting with the bash shell along with well-commented code. Highly recommended.

    --
    Meh.
  20. Obligatory. by pushing-robot · · Score: 3, Funny
    --
    How can I believe you when you tell me what I don't want to hear?
    1. Re:Obligatory. by grub · · Score: 1

      That is hilarious. Thanks :)

      --
      Trolling is a art,
    2. Re:Obligatory. by Yokaze · · Score: 1
      --
      "Between strong and weak, between rich and poor [...], it is freedom which oppresses and the law which sets free"
    3. Re:Obligatory. by Anonymous Coward · · Score: 0

      Still waiting for the obligatory bash.org reference ...

  21. I love this book by Anonymous Coward · · Score: 0

    I love this book. (well the older one)

    It's a must have for linux users that want to make something happen that isn't in the canned software.

    If your an old sysop from the past and you did lot's of batch file programming you'll LOVE this book.

    I have the older book, not this specific new one. Just cause you keep a paper cheat sheet doesn't mean you won't want to reference this book at times.

    The other book that kicks ass is the pocked sized book by O'reilly that has sys adm command reference.

  22. Holding Out by Jah-Wren+Ryel · · Score: 2, Funny

    I'm still waiting for jbosh, the Jason BOurne SHell, to be released. I hear it can really kick some ass.

    --
    When information is power, privacy is freedom.
    1. Re:Holding Out by corbettw · · Score: 4, Funny

      Do you really want a shell that runs out of memory and starts killing all of your processes?

      --
      God invented whiskey so the Irish would not rule the world.
    2. Re:Holding Out by mu51c10rd · · Score: 1

      Or even worse...after finishing off the processes, it goes after the kernel leading the whole thing.

    3. Re:Holding Out by Anonymous Coward · · Score: 0

      It would kick some ass, but you'd never find it because it'd be moving around your system disguised as csh or pretending to be 'ps' while stealing your .ssh directory.

    4. Re:Holding Out by nabsltd · · Score: 1

      C'mon, moderators...this is funny. Definitely the best of the Jason Bourne-related jokes.

    5. Re:Holding Out by Anonymous Coward · · Score: 0

      > Do you really want a shell that runs out of memory and starts killing all of your processes?

      Windows Explorer?

      *ducks*

    6. Re:Holding Out by Bill,+Shooter+of+Bul · · Score: 1

      No, Windows Explorer is more of a suicide bomber than a highly trained assassin.

      --
      Well.. maybe. Or Maybe not. But Definitely not sort of.
    7. Re:Holding Out by Zoxed · · Score: 1

      > I'm still waiting for jbosh, the Jason BOurne SHell, to be released. I hear it can really kick some ass.

      Only problem is it rarely follows instructions, and has a habit of disappearing for months and then popping up briefly to make you look stupid. Also its friend processes tend to wind up kill -9.

  23. Shell as a general-purpose language... by daedae · · Score: 5, Interesting

    True story:

    A guy I go to school with (I'm in CS, he's in physics) used to talk about how he was a Bash wizard. Since he was generally talking about writing scripts to submit jobs to a PBS-based cluster, I assumed he meant just in terms of rapidly submitting a large variety of jobs. One day he complains to me that his simulations were slow and wanted me to look at it with him to help him speed them up. So I say fine, send me the file...

    He'd written a particle physics Monte Carlo sim using Bash and Linux command line tools (in particular, there were calls to bc everywhere).

    1. Re:Shell as a general-purpose language... by Anonymous Coward · · Score: 1, Funny

      +1 bowing to my new master...

    2. Re:Shell as a general-purpose language... by morgan_greywolf · · Score: 5, Funny

      He'd written a particle physics Monte Carlo sim using Bash and Linux command line tools (in particular, there were calls to bc everywhere).

      Well, I, for one, welcome our new particle physicist bash programming overlord!

    3. Re:Shell as a general-purpose language... by colmore · · Score: 1

      Hey just throw more hardware at it right? His time on the hours he'd spend writing it in a faster language are worth more than the cost of a few new boxes, natch.

      --
      In Capitalist America, bank robs you!
    4. Re:Shell as a general-purpose language... by sconeu · · Score: 1

      Damn, that is hardcore scripting!

      I bow to the guys geekitude!

      --
      General Relativity: Space-time tells matter where to go; Matter tells space-time what shape to be.
    5. Re:Shell as a general-purpose language... by alexborges · · Score: 1

      I HAIL

      --
      NO SIG
    6. Re:Shell as a general-purpose language... by daedae · · Score: 2

      Such as it is, this is when I made him learn C. (I take no responsibility for him deciding to learn C++ though.)

    7. Re:Shell as a general-purpose language... by pjt33 · · Score: 1

      Surely it would be faster to write lots of it in bc so that he wouldn't have to keep spawning processes?

    8. Re:Shell as a general-purpose language... by pimpimpim · · Score: 1

      damn, someone beat me to it! I should hurry with my 2D particle MD code in powerpoint native visual basic then. Advantage is that it will do your visualization as well.

      --
      molmod.com - computing tips from a molecular modeling
    9. Re:Shell as a general-purpose language... by pimpimpim · · Score: 1

      C++ is not per se a bad choice. For one thing, it is easier to get a job if you know C++, compared to just C.

      And it doesn't have to be slow: In a HPC-course, one of the lecturers made clear that you can get fast code in C if you program it like you would program fortran code. Similarly you can get fast code in C++ if you program like you would program in C (and thus fortran). In short: treat everything in your main loop as a vector.

      Of course, if instead you base your main loop on reading data from and to objects, you might as well write your code in bash, from a performance point of view.

      --
      molmod.com - computing tips from a molecular modeling
    10. Re:Shell as a general-purpose language... by Plutonite · · Score: 3, Funny

      Bash scripting is dangerous. I wrote a client script to test a Helix multimedia server, once - we're talking millions of socket connections purely from a shell here (not even using netcat), and the professor gave us a B+ for the project. Needless to say, I wrote another script that summer, much smaller and more elegant, that thrashed and brought down the clueless bastard's website.

      Parents: talk to your kids about Bash, before someone else does.

    11. Re:Shell as a general-purpose language... by zunicron · · Score: 1

      True story:

      A guy I go to school with (I'm in CS, he's in physics) used to talk about how he was a Bash wizard. Since he was generally talking about writing scripts to submit jobs to a PBS-based cluster, I assumed he meant just in terms of rapidly submitting a large variety of jobs. One day he complains to me that his simulations were slow and wanted me to look at it with him to help him speed them up. So I say fine, send me the file...

      He'd written a particle physics Monte Carlo sim using Bash and Linux command line tools (in particular, there were calls to bc everywhere).

      True story:

      A guy I go to school with (I'm in CS, he's in physics) used to talk about how he was a Bash wizard. Since he was generally talking about writing scripts to submit jobs to a PBS-based cluster, I assumed he meant just in terms of rapidly submitting a large variety of jobs. One day he complains to me that his simulations were slow and wanted me to look at it with him to help him speed them up. So I say fine, send me the file...

      He'd written a particle physics Monte Carlo sim using Bash and Linux command line tools (in particular, there were calls to bc everywhere).

      This reminds me of the time the robot engineer made a robot that was the 'engine' of a particle physics simulator. It pushed a big arbitrary precision calculator for him quite quickly. The simulation was pretty fast. This is why usually need a CS degree to program.

    12. Re:Shell as a general-purpose language... by daedae · · Score: 1

      It's funny, in a kind of depressing way, actually. There are several people in this so-called "engineering physics" department who get into it with no particular knowledge of programming, even though all of the engineering physics students I know ultimately spend most of their time writing and running simulations. I've spent time with them doing everything from debugging doubly-linked lists to explaining how to use fscanf. Sure, they may know the math behind whatever they're trying to implement, but I think they're in that zone where if they weren't grad students, it would be much faster to explain to a programmer how the equations work than it is for a programmer to explain to them how to write what they want.

    13. Re:Shell as a general-purpose language... by Anonymous Coward · · Score: 0

      Ooh, you really showed him, you tough guy you.

      You're a dickhead with an overdeveloped sense of vengeance.

    14. Re:Shell as a general-purpose language... by Mr+Z · · Score: 1

      Further proof that Real Programmers can write FORTRAN in any language.

    15. Re:Shell as a general-purpose language... by Plutonite · · Score: 1

      Yeah, knowing how to write and defend against malicious scripts is indeed badass stuff. Hey it took all of 10 minutes to do, and he never noticed because everything was up again next day! Sorry if I came across as arrogant, dear coward. I was making a joke. Posting anonymously to insult someone, in contrast, is very manly and mature, touche ;)

  24. If we only had Chad 5 years ago! by lelitsch · · Score: 1

    Anyone who has used a derivative of Unix over the past 20 years has used Bash

    Wow, we could have avoided the entire SCO since AIX is not a derivative of UNIX.

  25. Ken Thompson wrote sh by Version6 · · Score: 1

    Ken Thompson wrote the original sh. In Unix Version 7 sh was replaced with the Bourne shell, confusingly also called sh. Some of us never really adjusted to the Bourne shell and over time switched to csh or ksh (the Korn shell written by David Korn). In my maturity, I recognize that it was all as inconsequential as vi versus emacs. (No contest really, vi is better.)

    1. Re:Ken Thompson wrote sh by homb · · Score: 1

      hehe. nice trolling at the end. let me add fuel to the fire and contend that since Perl became ubiquitous, shells have lost most of their programming importance.

  26. To Serve Webpages by AP31R0N · · Score: 3, Funny

    It's a cookbook!!!

    --
    Utilizing the synergization of benchmark e-solutions to pre-workaround action items!
  27. Standard Unix Shell? by plasticsquirrel · · Score: 2, Insightful

    To truly master a Unix environment, you need to know a shell, and Bash is easily the most popular of them.

    Bash is a fine shell, but it's certainly not the standard on Unixen today. Most versions of Unix still have the Korn/Posix Shell as the most common shell. This is certainly true in Solaris, HP-UX, and AIX. The BSD's typically don't use Bash, and favor more traditional, light-weight shells. However, some versions may package Bash in their distributions.

    Bash is really only the common default shell on Linux, from what I have seen. Things learned for Bash have similar syntax in other shells, but teaching newbies that Bash is the standard shell is a very bad, Linux-centric idea that leads to Bash-isms (people trying to use Bash-specific features in other shells).

    --
    Systemd: the PulseAudio of init systems
    1. Re:Standard Unix Shell? by Macka · · Score: 1

      Bash is really only the common default shell on Linux

      Bash is also the default user shell on Mac OS X too. And you can get it on HP-UX as well it you're willing to install the Open Source package collection that comes with the main distro.

  28. Feminists don't need this book by InterGuru · · Score: 4, Funny

    They can just enter "man bash" on the command line

    1. Re:Feminists don't need this book by Anonymous Coward · · Score: 0

      Actually, they type 'bash man' instead of 'man bash'

    2. Re:Feminists don't need this book by pjt33 · · Score: 1

      Wise in the ways of Yoda they are.

  29. But can it grill cheese? by Dareth · · Score: 1

    If I could write me a script that can make me a grilled cheese sandwich and I would very happy.

    --

    I only look human.
    My mother is a halfling and my dad is an ogre, so that makes me an Ogreling
    1. Re:But can it grill cheese? by AP31R0N · · Score: 1

      If you upgrade from Girlfriend 4.0 to Wife 2.0, you just might be able to do that. Just keep in mind that Wife 2.0 is more expensive in the long run and more likely to give you 403s. The cost of uninstallation if she finds Girlfriend 5.0 running in the background can be life ruining. But if you give Wife frequent upgrades, i hear it can be quite wonderful.

      --
      Utilizing the synergization of benchmark e-solutions to pre-workaround action items!
  30. Not as useful as it could be by Anonymous Coward · · Score: 0

    "bash Cookbook" suffers from a poorly thought out table of contents. For a 'cookbook' this lack of clean organization makes the book impractical as a reference source. After a few minutes of searching, trying to find the concept I need, I normally put the book back on my shelf and turn to Google. An online search always turns up better examples of what I'm trying to do and takes less time. Sorry O'Reilly, this book at best earns a C-.

  31. 4NT & Bash - better & worse ... by UnknownSoldier · · Score: 1

    I still miss the directory history (Ctrl-PageUp/Dn) from 4NT. I see one person does too and came up with solution

    1. Re:4NT & Bash - better & worse ... by tanguyr · · Score: 1

      hey cheers for that link!

      --
      #!/usr/bin/english
  32. Korn had problems by Anonymous Coward · · Score: 0

    mostly to do with patents or some other guff that (I think) is gone, but while there caused many problems.

    When you can't rely on many of the features of a shell, you're either portable to bash/sh or you're wasting your time on it and should consider using bash.

    1. Re:Korn had problems by Macka · · Score: 1

      Yeah. Most vendors I think got stuck with ksh 86 for many many years because of this, while ksh 93 languished on the shelf unused and unloved and left out of most distributions. ksh 93 was really very extensible and very powerful in its day. It was a missed opportunity.

  33. Small Warning for Ubuntu users: by Joe+Snipe · · Score: 2, Informative

    If you are new to linux and are thinking about learning BASH, you need to be aware that in Ubuntu linux /bin/sh points to DASH, NOT BASH. Not alot of difference, but it can screw you up if you are not aware of it. You know I'm not trying to troll here, but I really felt this change was poorly implemented and announced. I hope it doesn't deter any newbies from probing deeper into their systems and learning the joys of scripting.

    --
    Sometimes, life itself is sarcasm...
    1. Re:Small Warning for Ubuntu users: by Just+Some+Guy · · Score: 1

      You know I'm not trying to troll here, but I really felt this change was poorly implemented and announced.

      Had the system scripts not had out-of-spec Bash extensions, no one would ever have noticed the change. Those are supposed to be sh scripts, which dash handles just fine.

      --
      Dewey, what part of this looks like authorities should be involved?
    2. Re:Small Warning for Ubuntu users: by Anonymous Coward · · Score: 0

      But they did, as did (do) most systems. And everyone knew it. We are talking about thousands of scripts that may or may not have been posix compliant. There should have been more effort to make people aware of the change, and also to give the people upstream a headstart on fixing their scripts. Just doing it and hoping it all works out was a dick move, IMO.

  34. POSIX Standard? Then its not "Bash" by HighOrbit · · Score: 3, Insightful

    The review says, "They also use the POSIX standard, so that all of the examples are portable across platforms."

    So if the book and examples limit themselves to the POSIX subset of bash's capabilities and don't go into the GNU extensions, is the book really about "bash"? It sounds like the book could be called "UNIX shell cookbook" (oops already done) or "Ksh Cookbook" just as much as "Bash Cookbook". But of course, bash is the Linux default and Linux is hot while Unix is passe.

    I always thought it was the gnu extensions above and beyond POSIX (while staying backwards capatable with POSIX) that make the gnu tools like bash and gawk so much (allegedly) better than ksh and awk.

    BTW, I use bash because it is the default on most linux systems so I am familiar with it. Bash is the very first thing I install on BSD or Solaris systems and then I set it as my login shell. It's actually really rare that I need to call on the gnu extensions, so I could probably be happy with pdksh just as well.

  35. What's wrong with tcsh ? by Anonymous Coward · · Score: 0

    What does bash do that tcsh doesn't ?
    OK, aside from the 2>something_other_than_&1 stuff.

  36. Child processes by Dareth · · Score: 1

    My wife 1.0 beta (way past the alpha years) recently spawned a child process. She takes some resources, but so far the experience has been well worthwhile.

    Hmm, maybe I can try again to get her to cook/code me some grilled cheese. I know she has the algorithm and the resources, but she never seems to run that code.

    --

    I only look human.
    My mother is a halfling and my dad is an ogre, so that makes me an Ogreling
  37. And faint of heart by MarkusQ · · Score: 4, Funny

    And it's "faint of heart" not "feint of heart".

    And it would be "overviewing basic concepts" not "over viewing basic concepts" if "overview" were a verb.

    I made it as far as:

    I found Chapter 11 to be very useful (pun intended)

    before threwing in the trowl.

    --MarkusQ

    1. Re:And faint of heart by Random+BedHead+Ed · · Score: 1, Funny

      before threwing in the trowl.

      I should of done the same. I don't like picking apart people's writings, but it's a doggy-dog world.

    2. Re:And faint of heart by Anonymous Coward · · Score: 1, Funny

      I don't like picking apart people's writings, but it's a doggy-dog world.

      I could care less about things like that. Noone is perfect.

  38. Not the only choice by Just+Some+Guy · · Score: 5, Insightful

    I loved Bash (and was the maintained of the FreeBSD port of the Bash tab-completion for a while), but gave it up forever about a week after I tried Zsh. For me, it's like "Bash done right", from associative arrays for easy scripting to tab-completion that's fast and doesn't pollute the namespace with thousands of tiny functions:

    $ zsh
    $ set | wc -l
    167
    $ bash
    $ set | wc -l
    7221

    Which leads me to ask: has anyone tried Zsh but then gone back to Bash? If so, why?

    --
    Dewey, what part of this looks like authorities should be involved?
    1. Re:Not the only choice by Anonymous Coward · · Score: 1, Insightful

      Probably not. The only thing that zsh lacks is marketing power it seems. It's simply way better.

    2. Re:Not the only choice by nostrad · · Score: 1

      I did, the major reason when that I switched back was due to UTF-8 problems, and as far as I know the line editor is still blissfully unaware of multibyte characters.

      There was also trivial stuff like coloring the prompt, which for me makes things easier to find on a terminal full of text and additionally highlight that you're root (in addition to the #-sign).

      In all fairness, coloring (and probably everything else I was annoyed at) is doable and wouldn't have stopped me from trying it out a bit longer though.

    3. Re:Not the only choice by Just+Some+Guy · · Score: 3, Informative

      Coloring the prompt? That was the "gee whiz!" moment that made me switch permanently. From my .zshrc:

      # Import color definitions
      autoload colors zsh/terminfo
      colors

      # Define common and useful things to put in a prompt
      typeset -A prc
      prc[abbrevpath]='%{${fg[red]}%}%B%45<...<%~%<<%b%{${fg[default]}%}'
      prc[newline]=$'\n'
      prc[promptchar]='%(!.#.$)'
      prc[smiley]='%(?.%{${fg[green]}%}:).%{${fg[red]}%}:()%{${fg[default]}%}'
      prc[timestamp]='%B%{${fg[blue]}%}[%T]%{${fg[default]}%}%b'
      prc[userspec]='%B%(!.%{${fg[red]}%}.%{${fg[green]}%})%n@%m%{${fg[default]}%}%b'

      # Make a spiffy prompt
      PROMPT="${prc[userspec]} ${prc[timestamp]} ${prc[abbrevpath]}${prc[newline]}${prc[smiley]} ${prc[promptchar]} "

      # Unclutter the namespace
      unset prc

      See how all the colors are defined in an associative array, like ${fg[green]} gets you a green foreground? Say I'm in the directory "/usr/share/media/music/albums/Pink Floyd - A Momentary Lapse of Reason". As a regular user, my prompt looks like:

      kirk@athena [16:40] ...s/Pink Floyd - A Momentary Lapse of Reason
      :) $

      My name@host is green, the time is blue, and the path is red. The smiley face is green. Now, if I'm root:

      $ sudo -s
      root@athena [16:43] ...s/Pink Floyd - A Momentary Lapse of Reason
      :) #

      My name@host is red now, and the prompt char is "#" instead of "$". But what if I run a command and it fails?

      # crqecrqw
      zsh: command not found: crqecrqw
      root@athena [16:44] ...s/Pink Floyd - A Momentary Lapse of Reason
      :( #

      The green smiley face is now a red frowney face. Someone suggested a "big" prompt like that, and once I got used to it, I love it. It's very easy to see where command output stops and the next command starts, and the whole green smile vs. red frown thing is an instant visual indicator of a command's results (which sometimes isn't obvious, say if you're redirecting stderr to /dev/null). Sure, I could have done something similar in Bash, but I guarantee it would've been a whole lot less readable. I did that as an experiment to learn Zsh scripting, and I haven't deliberately used Bash since then.

      --
      Dewey, what part of this looks like authorities should be involved?
    4. Re:Not the only choice by Sosarian · · Score: 1

      $ zsh
      ~% set | wc -l
      157
      ~% bash
      $ set | wc -l
      184

      Or on another system:
      $ bash
      $ set | wc -l
                50

    5. Re:Not the only choice by Just+Some+Guy · · Score: 2, Interesting

      You don't have tab-completion enabled. I don't mean as in complete-the-filename but as in complete-the-command-arguments. For example, in Bash and Zsh with completion enabled, you can enter ifconfig <tab> and it will complete the interface name, or ssh -o<tab> to get a list of options that can be set (and then go on to tab-complete their possible values).

      I will never again voluntarily use a shell that doesn't support this.

      --
      Dewey, what part of this looks like authorities should be involved?
    6. Re:Not the only choice by Wdomburg · · Score: 1

      Eh? How does bash necessitate polluting your environment with variables ("set" shows variables not functions)? Gotta wonder what kind of retarded set-up you have on your box:

      [mberg@samedi ~]$ set | wc -l
      73

    7. Re:Not the only choice by Sosarian · · Score: 1

      So someone wrote a bash script that is somehow interfaced in a variable that shows up in set? And in zsh it's at a lower level? This set metric seems to be a bad way to compare shells anyways.

      I can see comparing on other features though.

    8. Re:Not the only choice by neurovish · · Score: 1

      wtf?

      $ set|wc -l
      88

      7221? How did you get that?

      I use both zsh and bash. I generally prefer zsh, but not so much to go and install it everywhere, so I'm usually in bash. The command switch expansion that zsh does is pretty slick though (try rpm - in zsh if you're on one of those type systems) and something I really miss when using bash. Aside from that, there isn't anything really killer that makes it a required upgrade for me.

    9. Re:Not the only choice by bonkeroo+buzzeye · · Score: 1

      I guess this topic's dead but: yeah, I tried it briefly and stuck to bash. Zsh was just really overcomplicated for me in what seemed like a "frilly" way. I'm willing to entertain the notion that I didn't give it a fair shake but I just didn't see anything I had to have - I can usually beat bash into submission and make it do what I want. For instance, I find my bash colors simpler and more readable than your zsh example, though I define the colors instead of having the shell do it for me:

      I create a ~/.pscolors:

      black="\[\e[0;30m\]"
      red="\[\e[0;31m\]"
      green="\[\e[0;32m\]"
      yellow="\[\e[0;33m\]"
      blue="\[\e[0;34m\]"
      magenta="\[\e[0;35m\]"
      cyan="\[\e[0;36m\]"
      white="\[\e[0;37m\]"
       
      gray="\[\e[1;30m\]"
      bred="\[\e[1;31m\]"
      bgreen="\[\e[1;32m\]"
      byellow="\[\e[1;33m\]"
      bblue="\[\e[1;34m\]"
      bmagenta="\[\e[1;35m\]"
      bcyan="\[\e[1;36m\]"
      bwhite="\[\e[1;37m\]"
       
      normal="\[\e[0m\]"

      so the relevant parts of ~/.bashrc are only:

      if [ -r $HOME/.pscolors ]; then
          . $HOME/.pscolors
      else
          echo "bashrc: can't read .pscolors"
      fi
       
      export PS1="\n${bgreen}[ ${bblue}\u${white}@${bblue}\h ${bgreen}]\
      [ ${magenta}\D{%m-%d %H:%M} ${bgreen}]\
      [ ${byellow}\w ${bgreen}]${normal}\n${white}:${normal}"

      which results in:

      [ j@surfandslam ][ 08-14 15:11 ][ ~/af/classic/Pink_Floyd_1971_Meddle ]
      :_

      where my background is black, the brackets are green, the @ is white, the username/hostname is blue, the date is magenta, and the working directory is yellow, the colon is white (and the underscore represents the cursor where everything typed is gray), and commands are separated by at least one blank line.

      In my 'set' output, I get 132 lines of variables (many of which are mine - including the colors since I don't bother to clean up the assignments), I use a truncated ~/.bash_completion that takes it to 587, and babble my own functions down to line 1013. So I'm more guilty of cluttering the environment than bash is and, also, coming from a DOS mentality, I *still* revel in being able to have a gigantic environment, so it doesn't bother me either way.

      Bash doesn't have associative arrays, but it has indexed arrays and awk has associative arrays. Etc. etc. I'm not saying bash is a perfect shell (by any stretch) or that zsh is a bad one. I just find bash more comfortable and think I might have felt the same way about ksh if that'd been my first *nix shell and would probably still feel the same way about zsh. (Except that ksh also has associative arrays, so I'd probably be slightly less interested in zsh.) (IOW, I'm more likely to switch to ksh than zsh, though I don't see ever switching to either.)

    10. Re:Not the only choice by Just+Some+Guy · · Score: 1

      7221? How did you get that?

      $ sudo aptitude install bash-completion

      This enables Zsh-like argument completion, but in a big, slow, and ugly way.

      --
      Dewey, what part of this looks like authorities should be involved?
    11. Re:Not the only choice by Just+Some+Guy · · Score: 1

      So someone wrote a bash script that is somehow interfaced in a variable that shows up in set? And in zsh it's at a lower level?

      In theory, it shouldn't make a difference. In practice, it makes tab completion a lot slower because it's running individual Bash functions instead of calling some C code, and it also means that I have about 7,000 more chances to accidentally clobber a helper function (or for a helper function to accidentally clobber something I've written).

      --
      Dewey, what part of this looks like authorities should be involved?
    12. Re:Not the only choice by Just+Some+Guy · · Score: 1

      Enable command argument completion and try that again. My "retarded" setup apparently has a whole lot more functionality than your bare-bones environment.

      --
      Dewey, what part of this looks like authorities should be involved?
    13. Re:Not the only choice by Wdomburg · · Score: 1

      Doesn't effect the number of environmental variables for me:

      [mberg@samedi ~]$ env | wc -l
      38
      [mberg@samedi ~]$ complete -p | wc -l
      0
      [mberg@samedi ~]$ . /etc/bash_completion
      [mberg@samedi ~]$ env | wc -l
      38
      [mberg@samedi ~]$ complete -p | wc -l
      500

    14. Re:Not the only choice by Wdomburg · · Score: 1

      Oh, bah. Somehow missed you were doing 'set' and not 'env'

      Still, using "set | wc -l" as a measure of namespace polution isn't exactly honest, since that includes the bodies of the functions. Looks like it's more like 185 functions:

      [mberg@samedi ~]$ set | egrep '^\{' | wc -l
      184

      And all but three of those are prefixed with an underscore:

      [mberg@samedi ~]$ set | egrep '^_' | wc -l
      181

      That's hardly unreasonable.

      Never bothered with command completion anyways. Most things are easier to just type out (or possibly pull out as a whole commend in an r-search).

  39. Bourne Again... by otis+wildflower · · Score: 1

    ... Starring Matt Damon.

    TIA.

  40. Waiting for the sequal... by Anonymous Coward · · Score: 0

    Bourne Again Supremacy.

  41. zsh rules! by Anonymous Coward · · Score: 0

    "Anyone who has used a derivative of Unix over the past 20 years has used Bash, ..."

    Sure, but in the end, people who really know what they're doing use the
    ultimate shell, zsh (see http://www.zsh.org/ )

  42. Suckers by otopico · · Score: 1

    tcsh and Pico! partners in crime and the only thing you will ever need... aside from root.

    if it isnt tcsh, it's crap.

    (also elm ftw!)

  43. The shell scripting with BASH book is... by CFD339 · · Score: 1

    Without question Ken O. Burtch's book "Linux Shell Scripting with Bash"

    Its extremely practical, very well organized, and covers just the right amount of related packages and use cases.

    On top of all that, its actually readable.

    --
    The problem with quotes on the internet, is that nobody bothers to check their veracity. -- Abraham Lincoln
  44. awk, and sed: choke ! by Macka · · Score: 1

    By Chapter 7, Bash Cookbook extends out of Bash commands and begins exploring combining the power of bash scripting with useful command such as grep, awk, and sed.

    Well I've not read the book, so I'm not sure what context he's using awk and sed in, but he should not be advocating the use these two unless it's absolutely necessary and only for occasional use. Under no circumstances should you ever make heavy use of them, especially when if you find yourself invoking them thousands of times inside a loop. The context switching it creates is a performance killer.

    There really is no need for it, as bash has a very powerful set of features for text manipulation that can be bent to almost any task. It may require writing a little more code to get the job done, but sticking with shell built-ins as much as possible to avoid context switching will result in much much faster execution times. The same goes for other shells too, like ksh, zsh, etc.

    I've re-written scripts for customers in the past to eliminate external programs as much as possible and reduced run times (for example) from several hours, to just 20 minutes.
     

  45. This guide ... by actionbastard · · Score: 2, Informative

    by Mendel Cooper, is all you will need. PDF. tar.bz.

    Save your money for beer.

    --
    Sig this!
  46. Bash gurus by dindi · · Score: 1

    I have seen bash gurus who could cat a file into sed, then run a regexp then count the output lines...

    Also many of these gurus could not check if a file existed, write a normal "if" comparing 2 variables, or write a script that w.g. found files at a place, ran grep on them, then depending on the output replaced strings in them, and created a diff directory.

    Now these books are NOT JUST for these guys, and I am sure even if you are that 3133t hax0r bash guru you can still find something new in these books.

    I am using bash since 92 (I know some since the 70's), and learn something new every week (at least) about bash or some pretty common UNIX command (grep, sed, bash sort, tar)......

    I am programming PHP and ASP (most of the time) and do it on Mac/OSX machines, so even working on Wintel machines I still have the edge using my unix cli (just mount the SMB sucker, then run the good stuff).......

    Then again, just my 2c, I just thought there were lot of bad critics here, and I though any book was a source for learning new. Or hey, just use google and "man", "man" (info) is your best friend under *NIX.....

    1. Re:Bash gurus by Anonymous Coward · · Score: 1, Insightful

      I am using bash since 92 (I know some since the 70's)

      That's very impressive. Bash was created in 1987 by Brian Fox.

    2. Re:Bash gurus by dindi · · Score: 1

      hahaha :)

      I just estimated the average response, that "OK big thing I am using it since 1902" ....

      Did not check my facts either, I really meant "sh", but

      "It was developed by Stephen Bourne, of AT&T Bell Laboratories, and was released in 1977 in the Version 7" [wikipedia.org] too ...

  47. Weakest. Pun. Ever. by Wowlapalooza · · Score: 2, Interesting

    I found Chapter 11 to be very useful (pun intended) finally grasping some concepts on the find command that have previously escaped me

    I think the Chapter 11 = bankruptcy folks have it completely right; the reviewer's attempt at humor was completely bankrupt here.

  48. Maybe C/++ might be unnecessary... by BrokenHalo · · Score: 1

    I know it's not really fashionable any more, but this is the sort of thing FORTRAN was made for. The right tool for the right job and all that...

    1. Re:Maybe C/++ might be unnecessary... by Tim+C · · Score: 1

      Indeed. My degree is in physics, and fortran (and especially doing exactly this type of numerical simulation with it) was part of the curriculum in the first and second year.

      The year I graduated, however, they dumped fortran and switched to C. I'm sure that was nothing to do with decommissioning most of the DEC Alphas and switching to PCs running NT though...

    2. Re:Maybe C/++ might be unnecessary... by BrokenHalo · · Score: 1

      ...and switching to PCs running NT though...

      Years ago (I think it was about 1990), Microsoft used to market (though I guess not very strenuously) a fortran compiler, "Microsoft Fortran". I never tried it, since I was working with mainframes at the time, but others have had good words for it. Most of us had never heard of the GNU Compiler Collection (I can't remember when gcc included the ftn frontend), so there weren't many ftn compilers available to fill the gap on x86 boxes unless you were prepared to write your own...

  49. http://www.scsh.net/ by Anonymous Coward · · Score: 0

    http://www.scsh.net/

  50. Feint? by johndmartiniii · · Score: 1

    Did you mean "faint-of-heart?"

    --
    If you don't know what you're doing, you can't make mistakes.
  51. Sorry but... by crawly · · Score: 1

    Sorry but i use CLISP for my shell.

    --
    GCS/S d-x s+(+): a C++++$ UL+$ P+ L++$ !E--- W++@ N++>$ !o !K-- w++$ !O !M !V PS++>$ PE !Y PGP+ t+ 5++ X++ R tv b
  52. Why I prefer bourne by walterbyrd · · Score: 1

    Bourne is more portable. Sun does not seem to like bash. Maybe it's just the "not invented here" thing.

    The way I see it, if you need something more powerful than bourne, use perl or python. Shell scripts are good for ten line throw-aways. The only possible advantage than shell scripting has over perl, is portability, so if you want portability, use bourne.

  53. Oblig. by rootooftheworld · · Score: 1
    --
    I know full well that tobacco is bad for you, so I smoke weed with crack