Previous Issue | Search TidBITS | TidBITS Home Page | Next Issue

TidBITS Logo


TidBITS turns practical this week, with the first installment in Kirk McElhearn's guide to the Unix command line for Mac users. Adam also explains how to speed up searching on the Internet with simple JavaScript-powered bookmarks in your Web browser. In the news, we report on the resounding success of PayBITS for raising funds for the EFF and call for your holiday gift suggestions. Finally, no issue next week: Happy Thanksgiving!


Copyright 2002 TidBITS Electronic Publishing. All rights reserved.
Information: <> Comments: <>

This issue of TidBITS sponsored in part by:


No Issue Next Week -- So we can all spend some relaxing time with our families and friends over the Thanksgiving holidays here in the U.S., we won't be publishing an issue of TidBITS next week on 02-Dec-02. I will continue moderating TidBITS Talk, and we'll be working on this year's annual gift issue during the extra week. We'll publish the next issue of TidBITS on 09-Dec-02, so until then, we hope those of you celebrating Thanksgiving have a great holiday! [ACE]

PayBITS EFF Donation a Rousing Success -- I'm overwhelmed. You've seen my reports about the amounts that PayBITS has generated, and for the most part, they've been sums that you wouldn't walk by on the sidewalk, but that wouldn't buy you a new Mac. In last week's article about the dangers of the DMCA, I said I'd donate all the PayBITS proceeds to the EFF to help that worthy organization continue to do their important work (which is increasingly done on Macs, by the way). I figured sending the EFF a hundred bucks or so would be a nice gesture, but I never imagined that my article would raise over $2,800 from more than 150 people (before PayPal transaction fees). The total amount was significantly boosted by very large donations from two generous individuals, but even without those, the amount would have been over $1,500. I think the lesson learned here is that many people felt strongly about the problems with the DMCA, about supporting the EFF, and about funneling the payment through us to show support for PayBITS, and for all of those things, I thank you. A few payments are still trickling in, so in another week or so, I'll figure out the total amount and send it to the EFF. [ACE]


BBEdit 7.0.1 Available -- Hot on the heels of the release of BBEdit 7.0, Bare Bones Software has released a free update to BBEdit 7.0.1. Among other minor fixes, the patch addresses conflicts with system-wide keystrokes under Mac OS X, improves BBEdit's new CVS support, tweaks processing of HTML and XHTML files, and offers a handful of FTP enhancements. You can read complete release notes on the Bare Bones Web site. Although most of the enhancements (and the focus) of BBEdit is for use under Mac OS X, BBEdit 7 does run under Mac OS 9.2.2, so classic Mac users aren't left out of all its text-munging goodness. The BBEdit 7.0.1 update is a 9.3 MB download. [GD]


Submit Your Holiday 2002 Gift Ideas -- It's time once again for that annual spectacle of consumer confidence, and if it's up to us individuals to prop up the global economy, the least we can do is make sure our favorite Macintosh-related companies come out smelling like roses! As with previous TidBITS gift issues, we'll focus on the best suggestions from you, our loyal readers. So tell us what gifts you're planning to bestow on your friends or family, or those things that you're hoping to receive yourself. As in previous years, we'll be collecting ideas in TidBITS Talk, so please send your suggestions to <>. We've already started threads for specific categories, and there's a "Respond (via email)" link for you to use at the bottom of each message in the TidBITS Talk Web archive. As always, please suggest only one product or idea per message, give the reason why you're recommending it, make sure to include a URL or other necessary contact information, and please recommend only others' products. If possible, suggest things that haven't appeared in past years. Thanks in advance! [ACE]


Hyperspatial JavaScript Search Bypass

by Adam C. Engst <>

If you're at all like me, searching is one of the main things you do on the Web. Perhaps you're searching in Google, looking up a word at, or just trying to find that TidBITS article you read a few weeks ago. Let me see if I can guess how you go about searching. First, you launch or switch over to your Web browser. Then you choose a bookmark, click a toolbar button, or just type the name of the site in the browser's address bar. After the page loads, you scan the page to locate the Search field, click in it, type your search phrase, and press Return. Phew! What a lot of work, just to perform a simple search! For some Web sites, though, you can bypass much of that effort.

(As a brief aside, to make sure you aren't wasting as much time as Windows users do, note that if you want to visit a Web site like, you can just type "apple" - minus the quotes - in the address bar and press Return. All Mac Web browsers can fill in the "www." and the ".com" for you, although you may have set recent versions of Netscape and Mozilla to ignore Netscape's annoying Smart Browsing feature by disabling the Internet Keywords option in Netscape's preferences). It's a great timesaving trick.)

The unnecessary parts of the standard approach to searching are visiting the home page of the site you want to search, waiting for it to load, and then finding and entering the Search field. Instead, you can embed an extremely simple JavaScript script in a bookmark, that, when clicked, pops up a search dialog and sends what you type in that dialog directly to the site's search engine, showing you just the results page.

In case you're starting to worry that this will require programming or get complicated, don't worry. I know absolutely no JavaScript either, and if you can edit a bookmark, you can use this script. I can't take credit for creating the script, either; I found it on the Web years ago, perhaps among the tools Google provides for simplifying searching. I merely figured out how to modify the script for my purposes, and that's what I'm going to show you.

Search Me -- Here then is the script that I use to search TidBITS directly. As you can see, there's almost nothing to it, and there are only two parts you need to understand.

javascript:void(q=prompt('Enter text to search for in TidBITS.',''));

First, in the parentheses after the word "prompt" is the text that will appear in the dialog that pops up after you click the script's bookmark. Enter anything you want there, but if your Web browser doesn't honor the spaces between words, replace them with %20. (I thought the %20 replacements for spaces used to be necessary, but they don't seem to be now.)

Next, look at the URL. As you can see, it ends somewhat abruptly after the equals sign. That's because the script appends the text you type in the dialog to the end of the URL, right after the equals sign. So, if you want to modify the script to work with a different Web site, you need to find a URL into which a search term can be inserted. With some sites, like, that's easy, since they display a readable URL that includes your search term in the address field after you search. In other cases, like Google, you may have to play with the URL a bit, deleting unnecessary parts and testing to make sure the URL still works. The URLs of many Web sites contain additional session or tracking information that's not strictly necessary. There are also Web sites like ours, where you're unlikely to guess the proper format for a search URL unless someone tells you. Lastly, for some sites, like Amazon, it may not be possible to start a search with a special URL.

There's no need for you to put effort into creating these scripts for Google or, since I've already done so.

javascript:void(q=prompt('Enter text to search using Google.',''));
javascript:void(q=prompt('Enter word to look up.',''));

Enhancing Your Browser -- Now you have three scripts you can use to search TidBITS, Google, and, and you have the basics you need to modify these scripts for other sites that will perform a search after being given a properly formatted URL. How do you build these scripts into your browser?

It's simple, although the process is different for every browser. Just create a bookmark or favorite, edit it, give it a descriptive name, and where the bookmark's URL normally goes, paste one of the scripts above. Although it may not matter in your particular browser, it's safest to make sure the entire script is all on a single line before pasting it into the bookmark's URL field. Some Web browsers don't accept Return characters in pasted URLs.

Since I do so much searching, I like to put the script's bookmark in the Web browser's toolbar. That's usually just a matter of making sure it's in the appropriate folder in the Bookmarks or Favorites window. Then, when I want to search, I switch to my browser, click the appropriate bookmark and type the words I want to find. No more visiting the site's home page just to find a Search field, and no more hunting down an obscured Search field.

For whatever reason, I'm not bothered by having to switch to my Web browser before performing the search. I suspect that's because my first subconscious thought is that I have to search on the Web, and only secondarily do I think about what site to search. However, if you use Internet Explorer (and possibly other browsers, though this trick did not work with the Chimera, Mozilla, and Netscape cousins), you can also drag the script bookmark from the Favorites window to your Desktop to create a stand-alone file that you can put it anywhere you want, such as your Apple menu in Mac OS 9 or your Dock in Mac OS X. You can also use the script file with any utility that can open a file, such as QuicKeys, DragThing, or the like. (Since many utilities can open URLs directly, you might think you could just paste the script into them directly, but in my experience, most don't know what to do with a JavaScript script instead of a plain URL.)

Searching Far and Wide -- There are undoubtedly many other techniques and utilities for speeding the process of searching various Web sites. I've tried a number of searching utilities over the years, including Apple's Sherlock, but none have ever quite grabbed me. It always felt as though they were adding another layer of effort to the task rather than simplifying it. However, if you have a technique you're particularly proud of, submit it to TidBITS Talk at <>, and if there are enough interesting submissions, I'll collect them and put together another article.

PayBITS: If this technique changes how you search, why not drop
Adam a few bucks via Amazon's Honor System. No account needed!
Read more about PayBITS: <>

A Mac User's Guide to the Unix Command Line, Part 1

by Kirk McElhearn <>

Lesson 1: First Steps with the Command Line

When Apple announced the release of Mac OS X, many Mac users were stunned: here was a new operating system based on the venerable Unix, which, they feared, would call into question the Mac's legendary ease-of-use. Mac users have long been staunch supporters of point-and-click interfaces, and Unix, or so they thought, was the exact opposite. Since Mac OS X presents a graphical user interface atop its Unix foundations, there is no need for worry - seasoned Mac users can feel right at home (after some adjustments) with the new interface, and not even know about the Unix underpinnings that make Mac OS X run.

Not everyone was apprehensive, however. Many Mac users, especially those who have worked in large businesses or educational institutions, have for years used Unix variants, or flavors, such as one of the many Linux distributions. They were delighted to discover that they could use their Macs and still wield the power of Unix (specifically, FreeBSD 4.4, one of the oldest and most stable versions of Unix). They can have access to the myriad command-line tools available for Unix and the powerful programs provided as standard equipment in Mac OS X, such as the Apache Web server, numerous network utilities, a compiler and more. And they can still benefit from Apple's easy-to-use graphical user interface.

Unix is reputed to be complex - its cryptic commands are said to offer a steep learning curve and not be accessible to "the rest of us." While this can be true - some Unix commands are like a foreign language - the command line can also be simple, useful, and powerful.

The goal of this article (the first in an occasional series to be published in TidBITS over the next year) is to present a brief example of how you can use Mac OS X's command-line interpreter, the Terminal application, to run a few simple commands, and see exactly how they work. You will discover, if you follow this easy tutorial, that Unix doesn't bite.

Opening Terminal -- Terminal is the program Apple includes in Mac OS X to provide the interface between the commands you type and the operating system. Terminal is a "dumb" program - it does little more than pass information on to a shell (another program that interprets these commands) and display the results of these commands.

Start by opening Terminal, which is located in the Utilities folder of your Applications folder (or, to use the Unix convention, /Applications/Utilities). Double-click the Terminal icon. The Terminal window displays, showing something like this:

   Last login: Mon Nov 25 16:03:03 on ttyp1
   Welcome to Darwin!
   [Walden:~] kirk%

This text tells you several things:

The prompt indicates that you can type commands. If Terminal is working on a command or displaying certain processes, you don't see a prompt. If this is the case, you can always open a new Terminal window to type commands; you can open an unlimited number of Terminal windows, called sessions, at any time.

Typing Your First Command -- Now that we've gotten through the basics, you're ready to type your first command. Let's start with echo, a simple command that displays what follows the command name in the Terminal window.

(Note: in the rest of this article, the commands and text you are to type are shown following the prompt sign, %, but without the localhost name and user name. You don't need to type the prompt text; just type what follows the % sign.)

Type the following:

   % echo Hello!

and press Return or Enter. Terminal displays the above line (the prompt and the text you type) as you type it. The echo command writes an argument to the Terminal's standard output; in this case, the Terminal window itself. After you press return, it displays the following line:


Your Mac just said hello to you! Now, you can go even further - after all, you don't know to whom it was saying hello. Try this command:

   % echo Hello $user!

My Mac says:

   Hello kirk!

All commands use a specific syntax - for simple commands, this is often just:

   command argument

Arguments are additional information required for some commands; other commands run with no arguments. In the line of text you typed above, the command was "echo" and the argument was the text you wanted Terminal to display.

That was easy, wasn't it? You have just used the command line under Mac OS X. The echo command is certainly simple, but it demonstrates basic command syntax and how Terminal works. (You've probably noticed that, after the above text, Terminal displayed a new prompt on the following line. This is a way of showing, as mentioned above, that the previous command has completed.)

You can now try typing the echo command with other text if you want.

Reading Directory Contents -- Let's see some more things you can do with Terminal. In the following series of commands, you will:

The Terminal prompt shows that you are in your Home (~) directory. Let's see what's in this directory. If you recall from looking at the Finder window, Home contains a few folders. Type the following (the first letter is lowercase L, not the digit 1):

   % ls

The ls command lists the contents of a directory. Terminal displays something like the following:

   Desktop    Library  Music     Public
   Documents  Movies   Pictures  Sites

This is a list of everything in your Home folder (it may be different depending on the contents of your Home folder). However, this list doesn't tell you which of the above items are files or folders. You can find out by typing the following:

   % ls -F

Terminal displays this list:

   Desktop/    Library/  Music/     Public/
   Documents/  Movies/   Pictures/  Sites/

The -F is an option for the ls command; it is also case-sensitive: -F is not the same as -f. Options tell certain commands to do things in a slightly different way. This option tells Terminal to display a slash (/) immediately after each pathname that is a directory, an asterisk (*) after each executable (application), etc. The slashes here show us that these are directories. If any of the above items were files, there would be nothing after their names.

Creating a New Directory -- Now, you're going to create a new directory called Test. Type the following:

   % mkdir Test

The mkdir command makes new directories. Let's check to make sure this directory has been created by repeating the ls -F command, which shows:

   Desktop/    Library/  Music/     Public/  Test/
   Documents/  Movies/   Pictures/  Sites/

There it is: Test/, the directory that you just created.

Now we are going to move into that directory, using the cd command:

   % cd Test

The cd command changes the current working directory. After running this command, the prompt changes to show that we are now in the Test directory:

   [Walden:~/Test] kirk%

As you've already learned, the ~ is a shortcut for your Home directory, and the slash means that the following directory resides inside the Home directory.

Creating a New File -- Let's now create a new, empty file inside the Test directory. Type this:

   % touch testfile

The touch command is typically used to update file access and modification times, but it can also create a new file; the argument, testfile, is the name we're giving to the file.

Let's check to make sure the file was created. Type:

   % ls -F

which should display the following:


Remember that the -F option for the ls command shows a / following a directory; it shows nothing for files. So we now have a new, empty, file called testfile sitting in the Test directory, just waiting for data to be put into it.

Writing Text to a File -- Since our file is doing nothing, we might as well write something to it. How about writing Hello [username]! in this file? To do so, we can use the echo command that we learned above. Type the following:

   % echo Hello $user! > testfile

This command tells Terminal to echo the text Hello [username]! to the file called testfile. Let's check and make sure it worked. There are several commands that display the contents of your files; one of them is cat. Type this:

   % cat testfile

Terminal should display:

   Hello [username]!

But since we only see this in the Terminal window, it doesn't give the same impression as when we open a document window in an application. Let's see what this file looks in a graphical application. Type:

   % open .

(Make sure you type open, then a space, then a period.)

This tells the Finder to open the current directory (the . is a shortcut for that) in a new window. You should see a new Finder window, entitled Test, with a file inside it called testfile.

Double-click the testfile icon, which should launch TextEdit and display a window containing the text "Hello [username]!"

Quit TextEdit to close the file, then switch back to Terminal by clicking its icon in the Dock.

Deleting Files and Folders -- Now that we have finished our brief demonstration, we need to clean up a bit. We don't need to keep that file and folder, so let's delete them.

Warning! The command line is not without certain risks. Unlike when you work in the Finder, some tasks you carry out are absolute and cannot be undone. The command I am about to present, rm, is very powerful. It removes files permanently and completely instead of just putting them in the Trash. You can't recover files after deleting them with rm, so use it with great care, and always use the -i option, as explained below, so Terminal asks you to confirm deleting each file.

Your prompt should look something like this, showing that you are still inside the Test directory you created earlier:

   [Walden:~/Test] kirk%

Type the following:

   % rm -i testfile

The rm command removes files and directories, in this case the file testfile. The -i option tells Terminal to run the rm command in interactive mode, asking you to make sure you want to delete the file. Terminal asks:

   remove testfile?

Type y for yes, then press Return or Enter and the file is removed. If you wanted to leave it there, you could just type n for no, or press Return.

We should check to make sure the file is gone:

   % ls

After typing ls, you should just see a prompt. Terminal doesn't tell you that the directory is empty, but it shows what's in the directory: nothing.

Now, move up into your Home folder. Type:

   % cd ..

This is the same cd command that we used earlier to change directories. Here, the command tells the Terminal to go up in the directory hierarchy to the next directory (the .. is a shortcut for the parent directory); in this case, that is your Home directory.

Type ls again to see what's in this directory:

   % ls

You should see something like this:

   Desktop    Library  Music     Public  Test
   Documents  Movies   Pictures  Sites

The Test directory is still there, but using rm, it's easy to delete it by typing:

   % rm -d -i Test

The -d option tells rm to remove directories. When Terminal displays:

   remove Test?

Type y, then press Return or Enter. (If you didn't remove testfile, as explained above, the rm command won't delete the directory because it won't, by default, delete directories that are not empty.)

Make one final check to see if the directory has been deleted.

   % ls

   Desktop    Library  Music     Public
   Documents  Movies   Pictures  Sites

Summing Up -- If you worked through this brief demonstration, you successfully typed commands in a Terminal window using the Unix command line. You created a directory (folder), created a file, wrote text to it, then deleted the file and the directory - and all with some very simple commands. Here's a brief summary of the commands you used:

Although you haven't accomplished anything extraordinary so far, you can see that using Terminal isn't that complicated. All it requires is a bit of time to learn the different commands and their arguments and options. But if you move ahead slowly, learning as you go on, rather than trying to memorize dozens of commands, you'll soon find that you are not only comfortable with the command line, but that you can do things that help you save time and give you much more power.

In the next installment in this series, you'll learn all how to move around in your computer's file system. I'll build on some of the commands presented here (cd, ls, mkdir, and others) and present many new, useful commands.

[Kirk McElhearn is a freelance writer and translator living in a village in the French Alps.]


PayBITS: Did this article help you dip your toes into Terminal?
Consider supporting Kirk with a few bucks via PayPal!
Read more about PayBITS: <>

Non-profit, non-commercial publications and Web sites may reprint or link to articles if full credit is given. Others please contact us. We do not guarantee accuracy of articles. Caveat lector. Publication, product, and company names may be registered trademarks of their companies. TidBITS ISSN 1090-7017.

Previous Issue | Search TidBITS | TidBITS Home Page | Next Issue