Correct typing errors in Terminal on Mac
If you make an error while entering a Terminal command, you can correct it before pressing the Return or Enter key to run the command.
In the Terminal app on your Mac, do any of the following to edit the current command line:
Move the cursor one character at a time: Press the Left Arrow key or the Right Arrow key.
Insert characters at cursor position: Type them.
Erase unwanted characters: Use the Delete key or press Control-H, then type the new characters.
Erase the line: Press Control-U.
Erase from cursor position to the end of the line: Press Control-K.
Reposition the cursor within the current command: Press and hold the Option key while using the mouse or trackpad to reposition the cursor.