« VJ software | Main | open firmware fixes »

terminal fixes

OK - one to remember in the old 'backup brain'

It's all about the carrots! (caret?!)
From macworld:

Let’s say you were trying to copy OS X’s built-in webserver configuration file, httpd.conf, to your desktop to take a look at (without worrying about damaging it). This file is located in the /etc -> httpd folder, and so your copy command would look like this in Terminal (the $ is the command prompt):

$ cp /etc/httpd/httpd.conf ~/Desktop/httpd_copy.conf

But in your haste to type the command, you type htttpd instead of httpd. (Yes, I’m aware you can use the Tab key to auto-complete paths in Terminal—and I highly recommend you do so. For purposes of this hint, assume my Tab key has been broken in a tragic accident.) Terminal then helpfully tells you:

cp: /etc/htttpd/httpd.conf: No such file or directory

This is right, of course; there is no htttpd folder. One way to fix this error is by pressing the up arrow, then the back arrow to move to the proper spot in the command, and finally pressing Delete at the right spot.

But here’s a potentially easier method: use the caret character (^). Immediately after you get the error in Terminal, start the next command with the caret, type in the portion of the prior command that you want to fix, type another caret, and then type the corrected version of the command. In this example, it was the three t characters that were wrong; it should only have been two. So to fix that, you’d enter this command:

^ttt^tt

When you press Return, Terminal will re-execute the prior command, making the correction you indicated. And to let you know what happened, Terminal will also echo the corrected command that was executed:

cp /etc/httpd/httpd.conf ~/Desktop/httpd_copy.conf

You may not use this every day, but it’s a nice timesaver for those times when you do make a mistake.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)