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:
Skip backwards or forwards over parts of a command you don’t want to change: 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 from cursor position to the beginning of 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.