Make PDFpen Your Default PDF Viewer
Want to open all your PDFs with PDFpen, rather than Preview or Adobe Reader? Follow these steps:
- Locate a PDF document in the Finder.
- Control-click the document.
- From the menu, choose Get Info.
- Scroll down the Get Info window to the Open with... pop-up menu.
- Choose PDFpen.
- Click Change All...
Other articles in the series By Your Command!
Who wields the most power in the Mac world? According to the annual MDJ Power 25, it's Steve Jobs. But Adam retains a spot in the top five for the fourth year, and we think we know why. Also, Kirk McElhearn explains how the command line can simplify certain file manipulation tasks, Adam reports on his current electronic book experiments, and we note the releases of GraphicConverter 4.8, Security Update 2003-08-14, TextWrangler 1.5, and DVD Studio Pro 2.
by Geoff Duncan
TidBITS Publisher Adam Engst #4 in MDJ Power 25 -- The results of the annual MDJ Power 25 survey are out, and TidBITS publisher Adam Engst has maintained a spot in the top five for the fourth consecutive year - fourth place this time aroundShow full article
TidBITS Publisher Adam Engst #4 in MDJ Power 25 -- The results of the annual MDJ Power 25 survey are out, and TidBITS publisher Adam Engst has maintained a spot in the top five for the fourth consecutive year - fourth place this time around. The MDJ Power 25 attempts to determine who truly wields power and influence in the Macintosh community by asking for the opinions of long-time industry insiders. For the second year in a row, Adam was the only member of the top five who is not an Apple employee. Apple CEO Steve Jobs was once again voted the most powerful person in the Mac industry (surprising no one), followed in second place by Apple's Chief Software Technology Officer Avie Tevanian and Apple Vice President of Software Engineering Bertrand Serlet in third place, with Vice President of Design Jonathan Ive in fifth. The reason for Adam's continued high ranking? The industry insiders consider TidBITS required reading, and they acknowledge Adam's continual efforts behind the scenes to make the Macintosh community a better place.
There's a trend in the voting toward assigning more power and influence to Apple employees (and primarily high ranking executives at that). In 2000 and 2001, 10 Apple employees made the list, 14 in 2002, and 16 in 2003. The spots they've taken have come at the expense of independent Macintosh developers (seven in 2000 and eight in 2001, but only three this year, if you count Dr. John E. Kelly of IBM, who makes the list only because he's in charge of the group that builds the PowerPC G5 chip). The numbers of writers, journalists, and publishers has dropped only slightly each year, starting at eight in 2000, dropping to seven in both 2001 and 2002, and six in 2003. One question is whether the trend reflects a concentration of power in Cupertino, which could impact the overall health of the Macintosh world, or if MDJ's choice of industry insiders (at least those who take the time to vote) has become skewed in some way toward Apple. There's also some potential confusion between power and influence: Apple employees wield great amounts of power (since almost anything they do affects Apple customers), but people like Adam, David Pogue of the New York Times (6th place), Ric Ford of MacInTouch (12th place), and Rick LePage of Mac Publishing (14th place) influence what we know, what we talk about, and the way we think. [GD]
by Geoff Duncan
Apple Releases Security Update 2003-08-14 -- Apple has released Security Update 2003-08-14 for Mac OS X, a 1.1 MB download available via Software UpdateShow full article
Apple Releases Security Update 2003-08-14 -- Apple has released Security Update 2003-08-14 for Mac OS X, a 1.1 MB download available via Software Update. The release corrects an off-by-one programming error in a FreeBSD networking function which could potentially be exploited to give a remote user root-level access to a Mac OS X system. The problem was originally found in the wu-ftpd FTP server, and impacts FreeBSD Unix and other FreeBSD-derived operating systems, including Solaris and some flavors of Linux. As of this writing, Apple has not provided any substantive information about the update; however, there are no known instances of this potential problem having been exploited under Mac OS X or any other operating system. [GD]
TextWrangler 1.5 Adds Scripting, Syntax Coloring -- Bare Bones Software has released the latest version of its streamlined text editor, TextWrangler 1.5 Show full article
TextWrangler 1.5 Adds Scripting, Syntax Coloring -- Bare Bones Software has released the latest version of its streamlined text editor, TextWrangler 1.5 . The primary new feature is the addition of full AppleScript support to enable TextWrangler to participate in automated workflow solutions involving text files. Better yet, any set of actions in TextWrangler can be recorded as an AppleScript script, and any script can be attached to built-in menu commands. TextWrangler 1.5 also now boasts syntax coloring and source-code navigation for code in Fortran, Java, Object Pascal, Perl, Python, Rez, Tcl, TeX, and Unix shell script.
Despite including BBEdit's core text editing engine, TextWrangler shies away from some of BBEdit's more-powerful features, such as flexible HTML tagging, integration with CodeWarrior, support for version control systems, and more. However, since TextWrangler costs $130 less than BBEdit, it has become popular with folks who seldom work with HTML files, those who find BBEdit's additional features overwhelming, and those who want much of BBEdit's power for a lower price. TextWrangler 1.5 sells for $50, but upgrades are free to registered users. It requires Mac OS X 10.2 or later with Mac OS X 10.2.6 strongly recommended. A 30-day, time-limited demo is available as a 7.6 MB download. [ACE]
by Jeff Carlson
DVD Studio Pro 2 Arrives -- Four months after announcing DVD Studio Pro 2 at the National Association of Broadcasters (NAB) conference, Apple has now shipped the professional DVD creation toolShow full article
DVD Studio Pro 2 Arrives -- Four months after announcing DVD Studio Pro 2 at the National Association of Broadcasters (NAB) conference, Apple has now shipped the professional DVD creation tool. DVD Studio Pro 2 is an extensive, ground-up rewrite of the original that incorporates technologies acquired when Apple purchased Spruce Technologies in 2001. The new version adds timeline-based track editing, a menu editor for customizing DVD menu systems, an improved MPEG-2 encoder, and plenty of design templates. The program's interface has been revamped as well, offering three different modes: Basic (similar to iDVD), Extended (more customization options), and Advanced (no pixel left unturned). DVD Studio Pro 2 integrates with Final Cut Pro 4, which was also announced at NAB and began shipping in June (see "Apple Ships Final Cut Pro 4" in TidBITS-684). The full version of DVD Studio Pro 2 costs $500, and upgrades from DVD Studio Pro 1.5 cost $200 (those who purchased version 1.5 between 06-Apr-03 and 15-Aug-03 can upgrade for a $30 shipping fee through Apple's Up-To-Date program). You need a Mac with at least a PowerPC G4 processor running at 733 MHz or better and an AGP graphics card, Mac OS X 10.2.6 or later, and a DVD drive for installation; although a SuperDrive isn't required to use the program, it is needed to burn projects to DVD-R media. [JLC]
by Jeff Carlson
GraphicConverter 4.8 Available -- In a product release we missed a couple of weeks ago, Lemke Software has updated its venerable image editing application GraphicConverter to version 4.8Show full article
GraphicConverter 4.8 Available -- In a product release we missed a couple of weeks ago, Lemke Software has updated its venerable image editing application GraphicConverter to version 4.8. As with previous updates, it's a wonder that anyone at Lemke gets any sleep: GraphicConverter 4.8 rolls together numerous improvements and fixes. For example, a new unskew effect has been added, as has the capability to swap color channels. Palm support has been improved with the addition of importing support for Foto PDB files and Palm image streams. Also, support for reading images directly from digital cameras and detecting images generated from Canon and Kodak cameras has been improved. GraphicConverter 4.8 runs under Mac OS 8.6 or later, including Mac OS X, costs $35 shareware, and is a 4.3 MB download. [JLC]
I remain fascinated by the evolution of electronic books, both those that started life on paper and those written purely for the digital world, so I'm continuing my experiments with both types. New 10 Quick Steps Guides -- Radio host David Lawrence (of Online Tonight and the new David Lawrence Show) has started a series of ebooks that he calls the 10 Quick Steps GuidesShow full article
I remain fascinated by the evolution of electronic books, both those that started life on paper and those written purely for the digital world, so I'm continuing my experiments with both types.
New 10 Quick Steps Guides -- Radio host David Lawrence (of Online Tonight and the new David Lawrence Show) has started a series of ebooks that he calls the 10 Quick Steps Guides. Each $10 guide follows a 10-step format that provides either a process or tips for accomplishing the task at hand. In an unusual twist, the 10 Quick Steps Guides are available both in PDF (formatted for reading onscreen) and in MP3 format for listening.
I've written two 10 Quick Steps Guides, one on avoiding spam that offers a series of interconnected strategies for getting spam out of your face, and another on how to make a Wi-Fi connection, using the information I gathered when writing The Wireless Networking Starter Kit.
So far, my Wi-Fi 10 Quick Steps Guide is outselling the Stopping Spam 10 Quick Steps Guide by about two to one, which surprises me. I expected the Stopping Spam 10 Quick Steps to be more popular both because I thought spam was a larger concern and because I wrote it completely from scratch, instead of repurposing the content from a more extensive book people can buy for about $25. That says to me there is a distinct audience for whom a concise electronic guide is more attractive than a longer traditional book.
Amusingly, David had an ex-spammer on his show shortly after the Stopping Spam 10 Quick Steps Guide came out, and the guy both confirmed what I described and agreed that the advice would indeed have worked against him. If your spam load has become distressing, check out the Stopping Spam 10 Quick Steps Guide for my recommendations, which go against the usual approach of setting up new email accounts each time an existing account starts receiving too much spam.
Also interesting is the fact that the PDF versions of the books outsell the MP3 versions about four to one. Most electronic publishers probably wouldn't do even that well, but it makes sense given that people think of David as a radio personality and know his voice. The audio versions of the 10 Quick Steps Guides should appear at Audible.com soon as well, so I'll be curious to see how well they fare there.
iPhoto 2 VQS Goes Electronic -- Moving from ebooks created to be read onscreen to those converted from traditional books, I've now made my most recent book, iPhoto 2 for Mac OS X: Visual QuickStart Guide, available in PDF format from Lockergnome. As with The Wireless Networking Starter Kit, which Glenn Fleishman and I also sell through Lockergnome as a PDF, the price of the electronic version of the iPhoto VQS isn't meant to cannibalize sales of the paper version, so I set it at $14, or roughly the cost of the paper version before shipping.
Of course, anyone who has already purchased the paper version of the iPhoto 2 VQS can get the electronic version for free (see the first page of the book), so the main reason to buy the electronic version is to avoid high shipping costs to international destinations, to take advantage of enhanced searching and navigation features, or if you simply don't want to use paper unnecessarily.
About 180 people have requested the free electronic version after buying the paper version so far; about 500 have downloaded the free (for anyone) electronic version of the older iPhoto 1.1 book, which you can access by sending email to <email@example.com>.
Changing Roles and Assumptions -- The main realization these experiences have triggered for me is that electronic books confuse much of the standard terminology that surrounds book publishing. We're used to authors writing lengthy books for publishers, who then rely on bookstores for sales, but in the electronic book publishing world, roles are different and assumptions change.
Electronic books written for purely digital distribution are seldom as long as a traditional paper book because people don't want to read as much at the computer screen, because there's no minimum size necessary for a book to avoid looking like a pamphlet, because many ebooks are relatively inexpensive, and frankly, because it's easier for the author. In fact, many ebooks are roughly the same length as a hefty feature article in a magazine; the main difference is that if you as a reader are looking for information on a particular topic, finding it in a current magazine is essentially happenstance, whereas you may be able to find an ebook that addresses your needs precisely.
In the ebook world, there's also little difference between publishers and bookstores. Traditional publishers put most of their effort into creating the book and pushing it into sales channels, but almost none into direct sales. That results in royalty rates for authors that top out at about 20 percent of the selling price to bookstores (the selling price is usually about half of the cover price).
In contrast, ebook publishers generally rely on authors to provide a mostly polished text in return for up to 50 percent royalties on the full price, and they put much more effort into sales and marketing; for instance, David frequently promotes the 10 Quick Steps Guides on his radio shows. Ebook publishers are also often happy to sell each other's books, and to give authors even higher percentages on direct sales the authors generate. That's why you'll see some of David's 10 Quick Steps Guides on GnomeTomes, and why David is setting up affiliate deals with companies like Audible.com.
All that said, the economics of ebook publishing still don't, for the most part, compare to traditional book publishing. An average computer book might sell 8,000 to 12,000 copies and generate between $5,000 and $15,000 for the author. In contrast, my experience is that ebooks are more likely to sell in the 200 to 2,000 range and generate more like $1,000 to $4,000 for the author. The big difference is in the time and effort necessary to create an ebook - it may be a matter of days or weeks from start to finish instead of months for a traditional book.
Don't make the mistake of assuming that these sales levels mean that the overall viability of electronic books is necessarily low. That's because each of these electronic publishers has their own audience - David's radio listeners, or subscribers to the Lockergnome newsletters - and there isn't necessarily much overlap in members, even if people in both audiences are interested in the same content. This fact is another reason these electronic publishers are more like bookstores - a bookstore in one town doesn't generally compete with a bookstore in another town because they have different geographic audiences, and the people buying from Lockergnome may never visit David's 10 Quick Steps Web site.
It's also highly unusual for a single bookstore to sell a few hundred copies of a book, as has happened with my 10 Quick Steps Guides and with the PDF of The Wireless Networking Starter Kit on Lockergnome, so I'm extremely happy with those results. The trick is that we need to create more of these topic-appropriate bookstores for electronic books; once that's done, electronic books might be able to achieve the sales levels of traditional books.
Lesson 3: Moving, Copying, and Deleting Files and Directories In the previous two installments in this series, we looked at the basics of using the Terminal to access the Unix command line at the heart of Mac OS X, and then at how to use the Terminal to move around your Mac's file systemShow full article
Lesson 3: Moving, Copying, and Deleting Files and Directories
In the previous two installments in this series, we looked at the basics of using the Terminal to access the Unix command line at the heart of Mac OS X, and then at how to use the Terminal to move around your Mac's file system. You might want to skim those articles for a quick refresher on some of the basics.
One of the strongest features of the Mac OS X Finder is its capability to make file management actions so easy that they seem effortless. When you drag a file's icon from one window to another, for example, the Finder puts a graphical face on a basic action, that of issuing a command to move a file from one location to another.
It's certainly quicker and easier to move icons in Finder windows than to type commands, but the command line offers advantages over using the Finder for moving, copying, or deleting files and folders (or directories). Here are just a few:
You can copy or move files from one directory to a distant directory, without having to navigate through intermediate windows.
You can easily copy or move multiple files using wildcards (a wildcard is a single character that represents one or more other characters). You can even select which files to copy according to certain attributes, such as parts of file names or extensions.
You can copy or move files that are hidden by the Finder.
You can move and rename a file or directory with just one command.
You can delete files or directories quickly, and use wildcards to match certain file name strings (such as .jpg, .rtf, and so on). These deletions are irreversible, so be careful!
You can delete files that the Finder refuses to delete; occasionally, a recalcitrant file you have placed in the Trash just won't go away. Using the command line, you can eliminate it for good.
As you become more familiar with working with the command line, you will discover more advantages to using it for file manipulation.
A Caveat on Moving and Copying Files -- The Mac OS has historically used a unique way of saving files: many files are in two parts, called the data fork and the resource fork. Back in the days of Mac OS 9 and earlier, the data fork contained data (the contents of a file, or code for applications) and the resource fork contained settings, icons, and other information. Most files used this multi-fork system, and, if you ever copied Mac files to a PC-formatted floppy disk and then looked at it on a Windows computer, you could have seen additional folders copied together with your files. These folders held resources forks; since Windows doesn't understand multi-forked files, putting the resource forks in a separate folder was one way of keeping Windows from deleting them altogether. Unfortunately, and almost shockingly, the standard Unix commands available in Mac OS X don't understand resource forks either.
When copying or moving files containing a resource fork, this can be a serious problem: some files still contain information in a resource fork, especially applications and those files created by Classic applications, as well as some Mac OS X-native applications. The cp and mv commands strip any resource forks they come across, potentially rendering the files useless. Apple addressed this problem by creating some additional commands, called CpMac and MvMac (the capitalization is important here), to resolve these issues, but for some reason, these commands are installed only with the Developer Tools, so most people probably don't have them installed. These command line tools enable you to copy and move files while retaining their resource forks, thus ensuring that everything you copy or move with them remains usable.
Another command, called ditto, has a -rsrcfork option, which, like CpMac and MvMac, allows you to retain resource forks when copying files.
Copying Files with cp -- The cp (copy) command does exactly what its name suggests: it copies files from one location to another. (This is the equivalent of pressing Option while dragging files in the Finder from one window to another on the same volume.) In its simplest use, cp copies a file (specified by its file name, with either a relative or absolute path) to a directory (also specified by its name, with either a relative or absolute path). The basic form is as follows:
% cp source destination
With this in mind, let's look at a few examples of copying files.
% cp ~/Documents/MyFile.rtf ~/Public
In the above example, I copied the file "MyFile.rtf" from the Documents directory in my Home directory to the Public directory, a location where any user can access files. As you can see, the first part, cp, is the command, the second, ~/Documents/MyFile.rtf, is the source, and the third part, ~/Public, is the destination. Both the source and destination in this example use absolute file paths; I could be anywhere in the file system when running this command.
However, if I were already in the Documents directory, I wouldn't need to use an absolute file path for the source. Since it's perfectly legal to mix absolute and relative file paths in a command, I could merely type the following:
% cp MyFile.rtf ~/Public
When copying files in this simple form, the source is a file name and the destination is a directory. (Though the destination can also be a file name; see below for more ways to use cp.) But the source can also be multiple file names. When executing this command, the shell (which is the Unix program that accepts your typed commands, interprets them, and displays the results) checks the contents of the directory you refer to, making sure that the file or files exist. If there are several files listed in what you've typed, and they all exist, then the shell goes ahead and copies them all to the destination. You can run a command like this to copy the three files after the cp command to the Public directory:
% cp MyFile1.rtf MyFile2.rtf MyFile3.rtf ~/Public
Using Wildcards to Copy Files -- For an even shorter version of the previous command, you can use a wildcard and save some typing:
% cp MyFile* ~/Public
The * wildcard tells the shell to look for all files whose names begin with MyFile, and copy them to ~/Public. Of course, if you have 10 files like that, all 10 will be copied. If you want only the first three copied, you must enter each name individually, or you could use the following command:
% cp MyFile[1-3].rtf ~/Public
If you want to copy all .rtf files from the source directory, you can use the following:
% cp *.rtf ~/Public
This command copies all files ending with .rtf to the Public folder. You can use the asterisk wildcard at any location in a file name.
Warning: Copying Files Replaces Existing Files -- By default, the cp command silently replaces any like-named files in the destination, unlike the Finder, which displays an alert asking if you really want to replace them. The same goes for the mv command (see below). This is one of the dangers of using the command line - new actions call for new habits, and the safest way to work with these two commands is to use the -i (interactive) option, which tells the shell to ask you if any files with the same name are present. When using this option, type
y for yes (to replace files) and
n for no. Here's an example:
% cp -i MyFile1.rtf New_Directory/ overwrite New_Directory/MyFile1.rtf? y %
If I had typed
n at the overwrite question, the command would have stopped without doing anything.
Copying a File and Changing Its Name -- In the above examples, the sources used were files and destinations directories. But the destination can also be a file name. This is useful if you want to copy a file and change its name at the same time. For example, to copy MyFile.rtf to your Public folder, renaming it MyFile1.rtf, run the following command:
% cp MyFile.rtf ~/Public/MyFile1.rtf
You can do the same thing to make a copy of a file, with a different name, in the same folder. Just run the command like this:
% cp MyFile.rtf MyFile1.rtf
Copying Directories with cp -- You can use cp to copy directories as well as files, but it works a bit differently. For cp to work with directories, it needs the -R (recursive) option. The -R option tells cp to copy not only the directory specified, but also all sub-directories it contains as well as any other contents. To copy a directory, you need to run a command using this basic form:
% cp -R source destination
All the other options and ways of copying, shown above for files, work the same with directories. Note, however, that while you can change the name of a directory during a copy, you cannot change the name of its sub-directories or other contents.
Moving Files and Directories with mv -- The mv (move) command moves files or directories from one location to another. It works just like when you drag files from one Finder window to another on the same volume. Note that if you run the mv command across volumes, the files or directories are removed from their original location, whereas the Finder normally copies them across volumes unless you hold down Command while dragging them. The mv command thus acts like a cut and paste operation, cutting the file or directory from its original location, and pasting it in its new location. The mv command works almost exactly like the cp command, the main exception being that you never have to use the -R option to move directories. To use mv, try the examples described above, substituting mv for cp.
% mv MyFile.rtf ~/Public/MyFile.rtf
In the above example, the file called MyFile.rtf is moved to my Public folder. The operating system first writes the file, then, after checking to make sure the copied file was written correctly, it deletes the original.
By default, the mv command (just like cp) replaces any like-named files in the destination. This behavior is unlike the Finder, which displays an alert, asking if you really want to replace them. You can run the mv command with the -i (interactive) option, as with many commands, to protect against this possibility.
Renaming Files and Directories with mv -- Since you can change the name of the destination when moving files or directories with mv, you can also use it to rename items, such as in this example:
% mv MyFile.rtf NewlyNamed.rtf
Unfortunately, renaming a bunch of files at once with wildcards (such as prefixing each of many files with a specific string) isn't trivial; the best way to do that is with the Add and Trim AppleScript scripts that Apple includes with Mac OS X; you can find them in /Library/Scripts/Finder Scripts.
Creating Directories with mkdir -- We have seen above how to move and copy files from one directory to another, but you may also need to create directories to put these files in. The mkdir (make directory) command is easy to use. Here's an example:
% mkdir Test
This command creates a new directory, called Test, in the current directory. Since the command does not begin with a /, the shell knows that you are specifying a relative path. If you want to create the same directory in, say, your Documents directory, you could run the above command after using cd (change directory) to move to that directory, or, from anywhere, run the following:
% mkdir ~/Documents/Test
The mkdir command can also make several directories at a time. If you want to create three directories, called Test1, Test2, and Test3, in the current working directory, you can run the following:
% mkdir Test1 Test2 Test3
If you want to create directories in hierarchy, mkdir can help as well. The only condition is that you set up your command in hierarchical order, creating the parent directory before the sub-directory, and before the sub-sub-directory, and so on. To create a series of directories and sub-directories like this:
you need to run the command as follows:
% mkdir -p Test1/Test2/Test3
The -p (path) option tells the command to create each intermediate directory as required. The command first creates the Test1 directory, then the Test2 sub-directory, and finally, further down in the hierarchy, Test3.
Removing Directories with rmdir -- The rmdir (remove directory) command is self-explanatory: it lets you remove directories, deleting them forever. Like the rm command that works on files, this command is extremely powerful: once you remove a directory, there is no getting it back.
However, rmdir works only with empty directories, whereas rm works with both directories and files, thus enabling you to delete a directory and the files in it. You may find it easier to use rm for both files and directories - it's easier to use one command instead of two.
To delete an empty directory, run the following:
% rmdir Directory1
You can remove several empty directories in one command. Just separate their names with single spaces, specifying either just their names (for relative paths, within the current working directory), or their paths (for absolute paths). Here's an example that removes three directories at once - Directory1, OldDocuments, and Video - and uses a different way of specifying each one:
% rmdir Directory1 ~/Documents/OldDocuments ../Video
You can also use rmdir to remove a hierarchy of directories, as long as all the directories are empty. Use the -p (path) option as follows:
% rmdir -p Directory1/Directory2/Directory3
One disadvantage to using the rmdir command is that, unlike the rm command, it has no -i (interactive) option, which asks you to confirm the deletion, and no -v (verbose) option; these deficiencies limit its value.
Removing Files with rm -- The rm (remove) command is one of the most powerful and dangerous commands you can use in the Terminal. Be forewarned: when you remove a file with rm, it is deleted forever. Although some file recovery programs may be able to find files deleted in this manner, it is safest to assume that files eliminated with rm are gone for good. Be even more careful with rm if you use it with the * wildcard, since it could wipe out all the files in a directory with no warning.
Although many Unix commands are safe to run, even if you have little experience, rm is like a loaded gun. For this reason, you should use it with the utmost care. However, there is a simple way to apply a safeguard to rm (and others); see below for a safety measure that takes the worry away.
Running the rm command is relatively simple. Look at the contents of this directory with ls:
% ls File1 File2 File3
To remove one of these files, run the following:
% rm File1
Check to make sure it worked with ls again:
% ls File2 File3
You can see that the file you removed is indeed gone; it no longer shows up in the list.
Safer Ways Remove Files -- The first way of removing files, as shown above, is really for those people who are confident with the command line. It's working without a net, though, and there is a simple safeguard you can use to protect yourself. The rm command has an option, -i (for interactive), which tells the shell to ask you to confirm that you really want to delete each file. To use this option, run the command as follows:
% rm -i File2
The shell asks you to confirm.
y for yes or
n for no.
remove File2? y
If you type
y, the file will be deleted. If you type
n, the file will not be touched. In both cases, the Terminal displays a new prompt; it gives no other information, and you need to use ls again to see what's in the directory.
Want an even safer way to remove files? Mimic the way the Finder does it and move them to the Trash. Then they won't be deleted until you empty the Trash manually. Try this mv command:
% mv MyFilertf ~/.Trash
Getting More Feedback with rm -- The rm command has another option, -v (verbose), which shows the names of files as it removes them. If you use this option, the shell shows the following:
% rm -v File3 File3 %
I have added the prompt after the file removal to illustrate how this displays. All this option does is show the name of the file, but it can serve to confirm exactly which file has been removed. Of course, if you made a typo and removed the wrong file, it's too late!
Removing Directories with rm -- Although you can use rmdir for removing empty directories, the rm command also lets you do this through the -d option. To remove a directory, use the following command, along with the -i and -v options for additional security:
% rm -div Directory1
The rm command can also remove directories recursively, using the -r (recursive) option, deleting a directory and all its subdirectories, as well as any files they contain. This is like dragging a folder, containing sub-folders and files, to the Trash in the Finder, except you can't drag it back out of the Trash if you want to keep it. If rm is a loaded gun, rm -r is a loaded bazooka. I cannot stress strongly enough how dangerous this command is, since you could blow away large numbers of files with a single mistake!
Let's look at how this works, and how you can use the -i option for minimal protection. First, create a few nested directories:
% mkdir -p Directory1/Directory2/Directory3
Then, to remove all three of these directories, run the following:
% rm -ir Directory1 remove Directory1? y remove Directory1/Directory2? y remove Directory1/Directory2/Directory3? y
Obviously, if you don't use the -i option, the command just removes all the directories without any feedback. But what if you decide you don't want to remove one of the directories? You can type
n at any point to keep it and each directory above it. Watch what happens then:
% rm -ir Directory1 remove Directory1? y remove Directory1/Directory2? y remove Directory1/Directory2/Directory3? n rm: Directory1/Directory2: Directory not empty rm: Directory1: Directory not empty
If, at any point in the hierarchy, you don't want to delete a file or directory, the system cannot let you keep an item without its parent directory. In the above example, the decision to not remove Directory3 means that Directory2 (its parent directory) could not be deleted; Directory1 (the parent of Directory2) also could not be deleted, so none of these three directories will be removed.
Summing Up -- This installment has shown you the essential commands for copying, moving, and deleting files and directories, as well as creating directories. These commands - cp, mv, rm, mkdir and rmdir - offer the same basic functions as normal Finder actions, but, as some of the examples show, offer more power and flexibility in certain situations. While the Finder remains easier to use for most operations, these commands give you a powerful alternative, with some capabilities the Finder cannot offer.
[Kirk McElhearn is a freelance writer and translator living in a village in the French Alps. This article is an excerpt from his forthcoming book, Unix for Mac OS X: Learning the Command Line, to be published by Addison-Wesley in 2003.]
PayBITS: Did this article help you dip your toes into Terminal?
Consider supporting Kirk with a few bucks via PayPal!
Read more about PayBITS: <http://www.tidbits.com/paybits/>
Scams aimed at users of PayPal and other sites -- More details on the PayPal scam spam, along with some complaints about how PayPal and eBay deal with reportsShow full article
Scams aimed at users of PayPal and other sites -- More details on the PayPal scam spam, along with some complaints about how PayPal and eBay deal with reports. (9 messages)
Text snippets while away from home -- Everyone seems to be interested in keeping interesting snippets of text, but what do you do if you're away from home? Solutions here. (4 messages)
Comments on VXA-2 -- Adam switched from the Exabyte VXA-1 tape drive to a FireVue-based hard drive backup strategy, but a reader is curious if anyone has tried Exabyte's VXA-2 tape drives. (1 message)
Apple's share of the PC market -- Every press article likes to point out that Apple has only 3 to 5 percent of the overall market, but does that matter at all? Some say yes, but others think it's a bogus statistic. (14 messages)
Serious data archiving -- We don't pretend that a hard drive-based backup strategy is appropriate for serious data archiving, so what is? (3 messages)
Building a better challenge-response system -- Challenge-response systems for reducing spam aren't inherently evil, it's just that most have significant problems. What's necessary to build a better one? (4 messages)
International power adapters -- What do you need if you're going to travel around the world with your PowerBook or iBook? Read this thread for the answers. (7 messages)
Complaints about the 17" PowerBook -- After Michael Shappe's review, there had to be some complaints, but we were expecting more than one. (3 messages)