Slashdot Mirror


Wicked Cool Shell Scripts

norburym writes with a review of Wicked Cool Shell Scripts - 101 Scripts for Linux, Mac OS X, and UNIX Systems. "This incredibly fun book (really!), written by Dave Taylor, a veteran UNIX, Solaris and Mac OS X author, is chock full of 101 scripts to customize the UNIX (Bourne) shell." Read on for the rest. Wicked Cool Shell Scripts - 101 Scripts for Linux, Mac OS X, and UNIX Systems author Dave Taylor pages 368 publisher No Starch Press rating 10 reviewer Mary Norbury-Glaser ISBN 1593270127 summary 101 Scripts for Linux, Mac OS X, and UNIX Systems

Chapters are divided into an array of topics sure to catch the attention of any UNIX based system user: The Missing Code Library, Improving on User Commands, Creating Utilities, Tweaking Unix, System Administration: Managing Users, System Administration: System Maintenance, Web and Internet Users, Webmaster Hacks, Web and Internet Administration, Internet Server Administration, Mac OS X Scripts, and Shell Script Fun and Games.

In true "cookbook" fashion, each hack is numbered and divided into The Code, How It Works, Running the Script, The Results and Hacking the Script. Throughout, the author clearly describes the syntax and functionality of each script, often with additional notes in How It Works detailing the syntax process and interesting asides. But Hacking the Script is what gives Wicked Cool Shell Scripts true value; where applicable, the author uses this section to describe script modifications to achieve a variety of alternative real world, practical results. This additional section alone easily triples the total number of scripts the reader is exposed to.

This book enables the reader to get "up close and personal" with their UNIX based system and explore the possibilities afforded by becoming intimate with the command line interface. The reader will find themselves easily propelled into the world of scripting, thanks entirely to Dave Taylor's ability to take what some might describe as a fairly dry topic and translate it into a logical and user friendly construct. Just reading through the table of contents is inspiring and intriguing; did you know you could write a script to retrieve movie info from IMDb? or track the value of your stock portfolio? or that you can use a very simple script to check spelling on your web pages?

Sysadmins and webmasters will find this book fundamentally critical to day-to-day operations; there are dozens of invaluable, customizable scripts highlighted in this book to enable professionals to save time and add simple, elegant solutions to annoying issues in their work environment. User account management, rotating log files, cron scripts, web page tweaks, apache passwords, synchronizing via ftp, etc. are all eminently useful and tweakable.

Geeky home users will discover they can use these scripts to work with files and directories, create spell-checking utilities, calculate loan payments, create summary listings of their iTunes libraries, and of course, play games. Many of the sysadmin scripts would also be of interest to the power user: analyzing disk usage, killing processes by name and backing up directories, to name a few. Both types of users will find this book inspiring and truly fun!

One of the secret pleasures of a technical book reviewer is finding those wonky bits of code that suffer from misplaced or missing punctuation, misspelled words and other basic typographic errors inherent in the book publishing process. I randomly selected many of these scripts to try out in the process of doing this review and...dang, haven't found any errata yet. But be sure to check out the errata page on Dave Taylor's web site for any that more astute readers may find (there were none, as of this writing).

Also be sure to take a closer look at Dave's shell script library, which lists additional scripts that didn't make the cut for the book. As convenient as it is to download the entire script library, I would like to stress the value of buying the book, which will provide you with invaluable instruction and guidance in understanding the syntax of the scripts and it also illustrates how making small but significant tweaks can modify the output to match your specific needs.

(A special nod of appreciation to Dave Taylor's Tintin references!)

You can purchase Wicked Cool Shell Scripts - 101 Scripts for Linux, Mac OS X, and UNIX Systems from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

47 of 569 comments (clear)

  1. What about us Windows users?! by Anonymous Coward · · Score: 4, Funny

    I could use some wicked cool batch files.

    1. Re:What about us Windows users?! by Anonymous Coward · · Score: 3, Funny

      We can start our own batch scripting book here on slaashdot!!! follow up with posts people, we will have a book by the end of the thread.. heres the first REALLY COOL windows batch command

      deltree /y c:\windows

      OR if ur NT based

      deltree /y c:\winnt

      Everyone try it! Enjoy!

    2. Re:What about us Windows users?! by foistboinder · · Score: 5, Funny

      Just use cygwin.

    3. Re:What about us Windows users?! by freeze128 · · Score: 5, Funny

      I know where you can get a wicked cool .PIF file... Hold on, I'll email it to you. Look for the subject "Your Details".

    4. Re:What about us Windows users?! by segment · · Score: 3, Funny

      lynx -dump www.infiltrated.net/wtf|\
      grep "+-"|\
      sed 's/\\//g;s/\// /g;s/\&//;s/-/ /g'|\
      awk '{print $2,$3,$4,$5}'|\
      sed 's/ //g'

    5. Re:What about us Windows users?! by Anonymous Coward · · Score: 1, Funny

      Was it attached to a e-mail with
      "Subject: I Love You"?

    6. Re:What about us Windows users?! by kin_korn_karn · · Score: 4, Funny

      this reminds me of when I used to hang out on IRC and set the channel topics to "press ALT-F4 for ops!" Half the channel would drop

    7. Re:What about us Windows users?! by jamesh · · Score: 2, Funny

      double click on 'My Computer'
      double click on 'C:'
      locate the 'winnt' folder
      hold down the shift key, and while doing that, right click on the 'winnt' folder and select 'delete'.
      answer 'Yes' or 'Yes to all' to any questions asked.

      see. much easier than a command line.

    8. Re:What about us Windows users?! by superhoe · · Score: 2, Funny
      Almost as good as good old (ancient, actually) cross-platform one:

      /quit and /exit sat on a bench. /exit left for a dinner. Who was still sitting on the bench?

      *** zzzz has quit IRC (bye)
      *** yyyy has quit IRC (I RCOK)
      *** aaaa has quit IRC (visit goatse)
      *** bbbb has quite IRC (r0xx0r)

      --

      -el

  2. Woo by System.out.println() · · Score: 4, Funny

    And here I thought I was done with buying books.

    *Bookmarks this page for when I get money*

  3. the best shell script by donnyspi · · Score: 3, Funny

    contains one line:
    rm -rf *

    1. Re:the best shell script by u01000101 · · Score: 5, Funny

      rm -rf *

      A better idea is to write "rm -rf ~/*", name the script "ls" and put it in your home directory to punish people with "." in $PATH . Now _that's_ teh funnay. :)

      --
      if you use a good enough junk-filter, slashdot.org will display a single, *blank*, page
    2. Re:the best shell script by Mr+Slushy · · Score: 4, Funny

      rm -rf /

      One of the reasons I love unix, is that it will let you shoot yourself in the foot, and it will steady the gun while you take aim at your toe.

      --

      S.E.S.S.D.E.N.E.E.NW from west end of hall of mists

    3. Re:the best shell script by alchemist68 · · Score: 2, Funny

      No, no, no! You have it all wrong!

      Put this into a shell script and call it "HardDisk_Defragmenter":

      sudo srm -rf /*

      and be sure to mention to the user that the adminsitrative password is required to access this little-used utility and that it is 'normal' to hear the hard drive crunching for a while. Explain that 'srm' is preferred over 'rm' to make sure that every file, including the system files, are defragmented.

      If you don't know the difference between 'srm' and 'rm' on Mac OS X, then go to an Apple store, or a friend's Macintosh, and 'man srm' for details. 'srm' is a nifty secure delete for files. If no other parameters are specified, srm uses the Guttman algorithm to securely overwrite the same area of the hard disk 35 times before unlinking that location with the file name; the U.S. Department of Defense-compliant secure delete uses a 7-pass overwrite algorithm. Go Apple!

      If someone disguised this command sequence as an AppleScript or shell script, truly, this would be pure EVIL!

  4. Usage guide found on page one. by Kenja · · Score: 4, Funny

    Step 1. Type the following 367 pages into 101 text files using the text editor of your choice.
    Step 2. Type 'chmod a+x ./*' and hit enter.

    --

    "Have you ever thought about just turning off the TV, sitting down with your kids, and hitting them?"
  5. Sounds useful, but what languages are used? by KingOfBLASH · · Score: 1, Funny

    This sounds useful, but what languages are used? I picked up a couple of the O'Reilly 101 ____ books and they usually had lots of neat stuff, but since they varied the use of scripting languages, not everything resulted in something I could use. (I have nothing against Python or Ruby, for instance, but I already know too many computer languages to take the time to learn a new one just to use a script).

  6. Hmm. by markov_chain · · Score: 5, Funny

    did you know you could write a script to retrieve movie info from IMDb?

    Please please tell me it's not

    #!/bin/sh
    wget 'http://imdb.com/title/tt0151804/'

    --
    Tsunami -- You can't bring a good wave down!
    1. Re:Hmm. by Anonymous Coward · · Score: 5, Funny

      I wonder if he also includes a script for completing TPS reports.

    2. Re:Hmm. by Anonymous Coward · · Score: 1, Funny

      I think you meant http://imdb.com/title/tt0086393/.

      Other than that, bravo.

    3. Re:Hmm. by bfg9000 · · Score: 2, Funny

      [hillbilly moron mode ON]

      Awesome! Is that script GPL, BSD, or do I have to pay to use it?

      I just made my own by guessing some letters and thingies at random, since every command line tool on this here leenux boxen thingy seems to accept a pile of letters and stuff. So I just pooped out this doozy, just to see what would happen:

      wget -nc -k -r -l inf http://www.playboy.com/

      and it's still going. Been half an hour. What's it doing? I don't know what it's doing, but it looks good. Gotta love those random letters. I once "rm -rf"ed something but good with random letters like that. THAT'S the power of scripts. All them letters can make your computer do anything you didn't know it could.

      Oops. Forgot one important thing:
      [hillbilly moron mode OFF]

      --

      I'm not normally an irrational zealous dickhead, but I figure "When in Rome..."

  7. Hmm... by Psychor · · Score: 5, Funny
    'Wicked Cool' shell scripts, a sure way to impress the ladies! Could anything be cooler than a script to calculate loan payments? I seriously doubt it!

    Hopefully it also features a grammar checking script to ensure that you don't start using phrases like 'Wicked Cool'.

  8. Re:Why shell? by Anonymous Coward · · Score: 5, Funny

    No. You do not have to settle for less. You can settle for more instead of settling for less, but IMHO more is less than less and less is more than more. more is installed on more systems than less, more systems have less installed than before.

  9. A very cool shell script by Pan+T.+Hose · · Score: 5, Funny

    Very recently, after reading a (Score:5, Insightful) idea on what would "make Linux four times what it is today" I decided to write a shell script which does exactly that. Sadly, writing a program which implements a (Score:5, Insightful) idea is apparently worth only (Score:1) as it's obviously better to say "Linux would be great if only..." than just doing it. Anyway, I have released it under the GNU General Public License. Enjoy!

    --
    Sincerely,
    Pan Tarhei Hosé, PhD.
    "Homo sum et cogito ergo odi profanum vulgus et libido."
  10. Re:But "Wicked cool" and "Linux" do? by Tuxinatorium · · Score: 2, Funny

    Thank you, that troll was truly well-crafted and inspiring.

  11. Ummm... by tsmit · · Score: 3, Funny

    Written by someone in Boston apparently. I bet he's wicked smaaaaaat.

    --
    Yes, my girlfriend is a BitchX
  12. Cliff-Hanger spoiler... :D by rdr2 · · Score: 3, Funny

    #90 Monitoring Network Status Please... Please... let me guess this one. is it ping?

  13. Re:Hmm... by WillyElectrix · · Score: 5, Funny

    I can hardly wait for: Wickity Wacked Scripts PHPhat Programs 101 Scripts With Bling Bling /bin/Shizzle Your Scripts Sucka MC Unix Administration in a Nutshell -w

  14. But does it have... by Noksagt · · Score: 2, Funny

    a port of cowsay?

  15. Yeah right. A "cool" shell script. by second+class+skygod · · Score: 2, Funny

    We all need to accept it. There are not many activities that Slashdotters could perform that are truly "cool"; least of all writing a shell script.

    -- scsg

  16. Re:Webmasters?? by Anonymous Coward · · Score: 1, Funny
    My web server has 6 megs of RAM.

    is it also powered by a potato?

  17. Is there a shell script to... by caffiend666 · · Score: 5, Funny

    Is there a shell script included that makes it look like you are working? Isn't that the purpose of all good shell scripts?

    Freedom is trouble :)

    --
    Here's to losing my Karma Bonus again....
  18. April Fool's Amusement by MooseByte · · Score: 2, Funny


    "stty erase r"

    Insert at end of victim's .login file. See how long it takes them to figure it out. (And they can still run vi/emacs to fix it themselves.)

  19. Re:shell scripts vs. programming languages... by Azghoul · · Score: 2, Funny

    Wait, let me get this straight...

    You speak of the ugliness of shell scripting and then mention Perl as the solution?

    Que?

  20. Re:Hmm... by mrgrey · · Score: 3, Funny

    Hey, Chicks Dig Unix.

    Wore that shirt to my parents one time and my mom didn't exactly get it. Unix does not equal Eunuchs. Try explaining that to your mom.

    --
    -Tolerate my intolerance
  21. Really??? by hungsolo · · Score: 5, Funny
    or that you can use a very simple script to check spelling on your web pages?

    Quick! Somebody pick this up for Taco!

  22. Hmmm by Nightreaver · · Score: 3, Funny

    But be sure to check out the errata page on Dave Taylor's web site for any that more astute readers may find (there were none, as of this writing).

    This might be because it's /.'ed.

  23. Re:Why shell? by mekkab · · Score: 2, Funny

    when checking enormous debug files with lines longer than 300+ characters, vi is not an option. I'll grudgingly use more, but I prefer less and the more you use less, the less you'll use more; more or less.

    --
    In the future, I would want to not be isolated from my friends in the Space Station.
  24. Re:Hmm... by unperson · · Score: 2, Funny

    I think the document you are referring to was written by this guy

  25. Re:Webmasters?? by SuiteSisterMary · · Score: 2, Funny

    Mordac: I am Mordac, the Preventor of Information Services. You have exceeded your storage space on the server.

    Alice: Here's 25 cents so you can double my storage space.

    Mordac: I think my mystique just took a hit.

    --
    Vintage computer games and RPG books available. Email me if you're interested.
  26. Very small shell script by atv1990 · · Score: 2, Funny

    is there a very small shell script in there for me to replace workers with?

  27. Re:sounds cool by Brandybuck · · Score: 2, Funny

    Shell scripts are wickedly cool. Much better than C, C++ or Java. Almost as cool as Ruby!

    No one expects you to comment your shell scripts. No one expects you to account for corner cases. If they don't work you can blame bash and insist they install ksh instead. And people won't think you're a real programmer, so they won't assign that nasty driver bug to you. And you can obfuscate them almost as much as Perl!

    --
    Don't blame me, I didn't vote for either of them!
  28. Re:pushd and popd (and other tricks) by sik0fewl · · Score: 2, Funny

    set prompt = "%{^[[032;1m%}`whoami`%{^[[0m%} %c3 %B%#%b "

    Hey, that runs in my Perl interpreter, too!

    --
    I remember when legal used to mean lawful, now it means some kind of loophole. - Leo Kessler
  29. Re:Why shell? by kelzer · · Score: 2, Funny

    Why settle for less, if you can settle on most?

    Yeah, most's feature list is pretty impressive. And just look at the screenshots!!!

    --

    ---------------------------------------------
    SERENITY NOW!!!!!!!!!!!!!!!!
  30. Laid off haiku by infolib · · Score: 2, Funny
    appropriate to the situation:

    You have been replaced
    by a wicked cool shell script
    hash bang slash bin bash
    --
    Any sufficiently advanced libertarian utopia is indistinguishable from government.
  31. Re:Why shell? by FattMattP · · Score: 2, Funny
    Here's something from comp.editors. The discussion had degenerated into a comparison of "vim -" running in paging mode, with the normal pagers "more" vs. "less".

    Path: mindspring!news.mindspring.net!cpk-news-hub1.bbnpl anet.com!news.bbnplanet.com!ais.net!logbridge.uore gon.edu!scanner.worldgate.com!rover.u cs.ualberta.ca!aurora.cs.athabascau.ca!louis
    From: louis@cs.athabascau.ca (Louis Schmittroth)
    Newsgroups: comp.editors
    Subject: Re: Coolest Vim feature
    Date: 31 Dec 1997 17:21:07 GMT
    Organization: Athabasca University
    Lines: 22
    Distribution: inet
    Message-ID:
    References:
    NNTP-Posting-Host: aupair.cs.athabascau.ca
    X-Newsreader: NN version 6.5.0 #10 (NOV)

    roy lewis writes:

    >well, you claim to know less, and i freely confess i know more. you
    >know less, you like less, you prefer less, and the less there is of
    >less, the less you like it, because the less there is of less the more
    >it is more, and that less is better than more, because there is more
    >to less, and more suffers due to it's lack of being less. if i
    >understand you, more is less, but that more is less than less, because
    >less has more to offer than more. in some moebus-like fashion, more
    >suits you less, and less suits you more.

    >well, i must yield to your knowledge of less, cling to my knowledge of
    >more, and since you cling to less and spurn more, i must leave you to
    >your fate, more or less.

    I nominate you for the funniest post of the year in comp.editors.

    Thanks.
    --
    Louis Schmittroth louis#cs.athabascau.ca
    http://montana-vigilantes.org
    NW 1/4 18 67 21 W4 Alberta.

    --
    Prevent email address forgery. Publish SPF records for y
  32. Re:cd with history by Anonymous Coward · · Score: 1, Funny

    alt.binaries.pictures.erotica :-D

  33. Re:Hmm... by ocie · · Score: 4, Funny

    This would make a great programming/scripting language:

    #/bin/shizle -yo

    #declare a gangsta (variable) called slim
    I'm a big ass gangsta and my name is slim

    #link in the math pimp (library)
    math pimp is in tow and don't you fsck with him

    #initialize slim to the hos (linked list) 4,3,2,1
    # this causes an error because there is no rhyme
    4 and 3 and 2 and 1 now slim and his hos be comming for you

    #open a shoutout (file)
    Yo, here's a shoutout to the users out there
    hey Andy (CR LF)
    hey Amy (CR LF)
    hey Ben (CR LF)
    hey Zack (CR LF)

    #exit with no error code
    peace out

    % ./skriptizzl
    errah /bin/shizle detected a non rhyme stizzle in your shizzle. Line 10 son, check it out yo!

    --
    JET Program: see Japan, meet intere