How we write in the terminal a patch or an expression containing spaces - UNEXPECED ARGUMENT

Photo of author
Stealth
Update:

In the application Terminal, every character means something. It can be a small part of a code, an argument in the command line or part of a script. The "space" is not exempt from this characteristic of the terminal. A "space" typed in the terminal in the argument of a command line, it will not be recognized as space. From here and error: Unexpected argument.

The simplest example is to use the tutorial in which we learn about How to change the Default (Desktop) location in which to automatically save Screen Shots on Macos.

If we want the folder in which to save Screen Shots will be "Screen Shots", then in the control line in the terminal we will have to define the argument for "space" correctly. Otherwise, after command line execution I'm going to meet a error.

Wrong Coamnda line:

defaults write com.apple.screencapture location ~/Desktop/Screen Shots 


To define a space between two words in the command line argument, we will use the character "\"Immediately after the first word.

Correct command line:

defaults write com.apple.screencapture location ~/Desktop/Screen\ Shots


Attention, the command line contains spaces. This tutorial is only valid for the arguments in the command line, which contain spaces. In our case, a folder whose name consists of two words by untied.

I've been writing passionately since 2004 about Windows and Linux operating systems, and since 2010 I've become a fan of Apple University. I'm currently writing tutorials for Mac, iPhone, iPad, Apple Watch, AirPods, and other Apple devices.

Leave a Comment