Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Books Media OS X Operating Systems Software Unix Book Reviews

Learning Unix for Mac OS X Panther 337

sympleko (Matthew Leingang) writes "In Neal Stephenson's manifesto In the Beginning was the Command Line , he writes about his favorite command-line utility: wc. As simple as can be, wc counts characters, words, and lines in a file. There's no GUI analogue, perhaps because anybody tempted to make one would add too many "features" that cluttered its ease of use. Think: do you know how to count the words in a Word file? BBEdit is a little easier, if you know the button to click." Read on for Leingang's review of Learning Unix for Mac OS X Panther, which seeks to reconcile the conception of user friendliness in OS X's Aqua with the sometimes-denigrated command line.
Learning Unix for Mac OS X Panther
author Dave Taylor and Brian Jepson
pages 168
publisher O'Reilly
rating 8/10
reviewer Matthew Leingang
ISBN 0596006179
summary Nice and Easy

You can do a tremendous amount of stuff in Mac OS X Panther without ever touching the command line. This includes editing files, transferring them to remote locations, running a web server, and writing programs. Legend has it that some Apple developers wanted to ship OS X without a command-line application because it's anathema to the Mac "experience." But as Unix geeks will tell you, there are tasks which are much better suited to the command line. Routine, repeated, and automated tasks are some, as well as quick-and-easy access to files and directories.

This book is for the skilled Mac user who would like to know a little more about the operating system behind the scenes. There's also information about the Mac's brand of Unix, so someone familiar with Unix but new to the Mac will also find stuff to learn. For those confident in their Mac and Unix skills, however, there's not much new in the book's 168 pages. That's not to say it's a bad book; I found it quite enjoyable to read, and it's a good title to keep in mind to recommend to a Unix novice.

The book begins with an introduction to Terminal.app, the Mac's Unix terminal program. From the very basic (how to find with the Finder) to the fun (how to change the text and background colors) to the useful (how to save terminal sessions into double-clickable .term files), there's much that Terminal has to offer. There's even the cryptic echo '^[]2;My-Window-Title^G' command to change the title of Terminal's window.

The authors then introduce a few simple commands like date and who, and show how to manipulate the terminal's prompt. There's also alias which creates command shortcuts. For instance, if you always run ls with the -F flag, a command alias ls "ls -F" will save you some typing.

Each chapter has two sections which stand out. The "Practice" section gives a list of exercises to try, and the "Problem Checklist" is there to diagnose and fix unexpected behavior.

It's important (especially for those used to other OSes) to understand that in Unix, everything is a file, and all files are organized in the filesystem. This includes plain files, which might be Word documents or system logs; directories, which break up the filesystem into a tree; links, which allow file reuse with different names; devices, drives, etc. All these building blocks of the operating system are discussed. There are also a few pages on vi (which I found quite useful as my vi knowledge up to that point consisted of :q!.) and pico.

Printing on Mac OS X is much like printing on any Unix operating system; you can use pr to format text for line printing, enscript to format for PostScript printing, and lpr to actually queue a printer job. The addition that the Mac provides is a CLI to AppleTalk printers. You can use at_cho_prn to choose an AppleTalk printer and atprint to print to one.

One of Unix's biggest features is its ability to put together small programs to do many different tasks. To count how many files under your home directory are named foo, you can do find ~ -type f -name "foo" | wc -l. By breaking down a problem into components, you only need one-counting program, one file-finding program, etc. The book has a good chapter on this input/output redirection, and how to use those magic top-row characters |, >, >>, and <. Grep (and some light regular expressions) and sort are mentioned as tools for examining text. I thought sed would make a nice addition to this chapter, but perhaps it would lengthen the book too much.

Another advantage of Unix is its true multitasking. What may surprise newcomers to the command-line is that it is possible to run many jobs at once with a single interface. By running commands in the background, one can start large jobs and do other tasks while waiting. In the chapter on multitasking, the & modifier is covered, along with fg, bg, and kill to manipulate processes, and ps and top to report on them.

The command-line interface is lightweight enough that it can easily be extended by a network. This means it's easy (in fact, commonplace) to control a computer different from the one in front of which you're sitting. The authors cover the remote-shell commands ssh and its non-secure cousins, as well as other tools for accessing the internet such as ftp and curl.

The book closes with an introduction to the wealth of open-source software available for Macintosh, now that Macs run a functional Unix. The graphical Unix applications require an X server, which is easy to download and install. The authors show how to install Fink, the Macintosh open-source package manager, and a few big applications like OpenOffice.org and The Gimp.

The last chapter is both a resource list and suggestions for further directions. Those who learn a lot from this book may be interested in picking up shell programming or a scripting language such as Perl.

As I said at the beginning, the book is basic and well-written. Even if you feel it's beneath you, keep the title in mind when a newbie asks what the command-line is all about.


Matthew Leingang is a Preceptor in Mathematics at Harvard University. A funny sentence in the third person escapes him at the moment. You can purchase Learning Unix for Mac OS X Panther from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

This discussion has been archived. No new comments can be posted.

Learning Unix for Mac OS X Panther

Comments Filter:
  • Linguistic origins (Score:4, Informative)

    by 2.7182 ( 819680 ) on Friday November 12, 2004 @04:11PM (#10801443)
    In an old paper by Ritchie, it is pointed out that Unix comes from the Old Dutch, Unochs, which means "tree-based".
  • by Anonymous Coward on Friday November 12, 2004 @04:13PM (#10801466)
    BBEdit is a little easier, if you know the button to click.


    Yea, the big freaking button with "i" in a circle right in the middle of toobar. It will tell you characters, words, lines and pages. Even easier and faster to use than wc.

  • by CerebusUS ( 21051 ) on Friday November 12, 2004 @04:13PM (#10801475)
    And if word count is that important to you, you can always add it to the toolbar. Then it's just a matter of hitting "Alt-C"
  • by YU Nicks NE Way ( 129084 ) on Friday November 12, 2004 @04:14PM (#10801483)
    Did you know that the number of words in a document is not a single value, but depends on the use of the document? I'm sure that Stephenson does know that: if you're writing for some audiences, you don't count the words in foot- or endnotes, whereas for others, you do. If you're writing for some audiences, you don't count "short words", whereas for others, you do.

    And, of course, if you're writing in Japanese, wc counts your entire document as being one word long.

    What does this have to do with Unix? It's a classic example of Einstein's dictum that everything should be made as simple as possible, but no simpler. The Unix command wc is a classic exmple.
  • by ikewillis ( 586793 ) on Friday November 12, 2004 @04:22PM (#10801570) Homepage
    Wrong. The name Unix is an abbreviation of UNICS, which stands for UNiplexed Information and Computing Service, a play on MULTICS, MULTiplexed Information and Computing Service
  • Re:Good points (Score:5, Informative)

    by AKAImBatman ( 238306 ) * <akaimbatman@gmaYEATSil.com minus poet> on Friday November 12, 2004 @04:23PM (#10801579) Homepage Journal
    Not to mention the Fink project, which adds tons of great apps to the command line.

    Fink is nice, but it tends to make something of a mess. Even worse, that mess is mixed in with your current files, making it difficult to clean up later. I've found that http://packages.opendarwin.org [opendarwin.org] works better. Don't access it through your web browser. just select finder, then click on the "Go" menu, then "Connect to Server...". Place that URL in the textfield and click "OK". You should now have a WebDAV archive of opensource binaries mounted on your desktop.

    Have fun!
  • I am wiser now. (Score:3, Informative)

    by kahei ( 466208 ) on Friday November 12, 2004 @04:30PM (#10801668) Homepage
    The fact that Neal Stephenson, the commentator, and the person who accepted the article were able to write and read so much about the subject without ever noticing all the obvious and commonly used GUI counterparts to wc -- many of which are considerably more interesting, for instance Word does a little morphological analysis to count Japanese words -- says something desperately sad about those people and perhaps about the culture they are from.

    But the fact that so many slashdotters stepped up already and cared enough about nitpicking the record straight that they have posted the path to the word count tool in Word at least half a dozen times already, fills me with hope!

    I feel as if I have gained wisdom from this simultaneous despair and revival. The feeling is probably false, though.

    Incidentally, the finest and most satisfying way to count words (if wc's answer is good enough) is to use wc... from vim.

  • Re:Good points (Score:4, Informative)

    by bsartist ( 550317 ) on Friday November 12, 2004 @04:36PM (#10801725) Homepage
    Even worse, that mess is mixed in with your current files

    Wrong. Everything Fink installs is found under /sw - *nothing* is "mixed in with your current files".
  • by smcdow ( 114828 ) on Friday November 12, 2004 @04:36PM (#10801729) Homepage
    What if you want to count all the word and excel documents that contain the phrase "unix can jump up my ass"? Huh, jack? Where's your command line tool for that?
    find ~/. -type f | egrep '\.(doc,xls)$' | xargs grep -l 'unix can jump up my ass' | wc -l

    Easy peasy.

  • Guys,

    The default install of Word 2004 for Mac always shows the word count, in the lower right hand corner. It shows it as XXX/YYY, where XXX is how many words are before the cursor, and YYY is for the entire document.

    As a professional writer, I can't imagine what wc would offer me that would be better than that! I often work on very specific total word targets for articles, so I can track if I'm under or (much more likely) over, and tweak accordingly.

    Personally, I haven't been able to use Word on Windows since they started putting the icons in the wrong place in the menus. The PowerBook 17" is the ideal writing machine today, in my opinion.
  • by Chess_the_cat ( 653159 ) on Friday November 12, 2004 @04:41PM (#10801789) Homepage
    And don't even get me started about the menus with chevrons! Assuming for the sake of argument we are talking about the current version of WORD, have YOU ever tried to walk someone through this kind of stuff over the phone? With MS' genius implementation of self-modifying menus, you could "claim" something is in a menu when trying to help someone when in fact because of their use menus, their menu is completely different from yours.

    Without knowing where it was beforehand it took me about 5 seconds to find the following:

    Right click on any Toolbar, Customize, Options, and check "Always show full menus."

  • Re:Good points (Score:3, Informative)

    by justMichael ( 606509 ) on Friday November 12, 2004 @04:42PM (#10801796) Homepage
    Fink is nice, but it tends to make something of a mess. Even worse, that mess is mixed in with your current files, making it difficult to clean up later.
    Umm, not to sound like an ass, but...

    1) Launch Terminal.app
    2) sudo rm -rf /sw
    3) Fink is nothing but a memory ;)
  • by DoctorPepper ( 92269 ) on Friday November 12, 2004 @04:50PM (#10801863)
    Try WinGrep [wingrep.com]
  • I call shenanigans! (Score:3, Informative)

    by quandrum ( 652868 ) on Friday November 12, 2004 @04:54PM (#10801906)
    It's even easier in MS Office v. X ( and we are talking about OS X, right?), it's in the freaking status bar, right next to page count and line count. I don't even have to use the mouse or the keyboard.

    This is embarrassing.
  • by meabolex ( 788745 ) on Friday November 12, 2004 @04:57PM (#10801938)
    If you don't know how to do a word count in a command line environment then you must resort to looking it up in help.

    Ohh! The agony!

    Google: word count unix: First return:
    This utility displays a count of the number of characters, words and lines in a file.

    1.14 Type the command

    $ wc temp

    This prints out a list of the number of lines, words, and characters respectively.

    The switches for this utility are
    -l print line count
    -c print character count
    -w print word count
  • by killjoe ( 766577 ) on Friday November 12, 2004 @04:58PM (#10801948)
    Use CRM114 [sourceforge.net] Instead of grep.

    It's been described as "like grep if it was bitten by a radioactive spider". In a nutshell it allows you do define sliding windows and search for phrases inside those windows.

    It's way cool.
  • by plog ( 816386 ) on Saturday November 13, 2004 @02:30AM (#10805510) Journal
    And some of us "Unix guys" (since 1977 or so, in my case) use GUIs for some things and CLIs for others.

    I'm a 'desktop guy' but I first dicovered computers through TeX in 1980, and keep a Terminal window open half the time. I too bounce back and forth.

    Then there's Quicksilver [blacktree.com] on OS X, with its hybridity; keyboard control full of CLI hooks, anticipatory bold-and-fast GUI feedback, and it's now being extended well past a search/launch core function. It's both GUI and CLI and neither.

    I'm using it more and more on its own. File name completion good iconic feedback really makes things feel instantaneous.

    I enjoy the tired old desktop, but I'm hoping something like Quicksilver will replace it.

  • by Anonymous Coward on Saturday November 13, 2004 @03:03AM (#10805576)
    Let's say you have 50 documents and you need to know for some reason the word count or line count of each. Are you going to open up Word (or your fav editor) 50 times for that?
    wc -w *.txt
    This, for e.g., comes in useful when you need to count the total no. of lines of source code in a project (with multiple files in subdirs).
    find -iname "*.c" | xargs cat | wc -l

He has not acquired a fortune; the fortune has acquired him. -- Bion

Working...