If you’ve spent time in Terminal, more than likely you’ve made a typo or two—or two hundred thousand, if your typing accuracy is anything like ours! It’s one of the banes of working in Unix—after years of point-and-click, having to type sometimes long and complex commands by hand leads to inaccuracies. And, sad to say, Terminal isn’t nearly as lenient with typos as are Word and other text editors.
As an example, let’s say you were trying to change the directory to the Applications folder. The command would look like this in Terminal (the
% is the command prompt):
% cd Appplications
But in your haste to type the command, you type
Appplications instead of
Applications. Terminal then helpfully tells you:
cd: no such file or directory: Appplications
One way to fix this error is to use the arrow keys to move to the proper spot in the command, and press Delete at the right spot. (And yes, this command is short enough so that re-entering it completely isn’t complicated or takes much time. Go with us here, it’s an example.)
Here’s a potentially easier method for more complicated commands: 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
p characters that were wrong; it should only have been two. So to fix that, you’d enter this command:
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:
% cd Appplications cd: no such file or directory: Appplications % ^ppp^pp cd Applications [email protected] Applications %
You may not use this every day, but it’s a nice timesaver for those times when you do make a mistake.