MacOS tweaks

How we write in a Terminal a path or an expression that contains spaces - Unexpected argument

In application Terminal, each character means something. It can be a small part of a code, an argument in the command line or part of a script. Neither "space" is exempt from this Terminal feature. A "space" typed in the Terminal in the argument of a command line, it will not be recognized as space. Here's the error: Unexpected argument.

The simplest example is to use the tutorial we teach about how to change the default desktop location to automatically save screen shots to macOS.

If we want the folder to save screen shots to be "Screen Shots," then in the command line in Terminal we will have to define the argument for "space" correctly. Otherwise, after executing the command line we will meet her error.

Wonderland:

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 "\"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 only applies to command line arguments that contain spaces. In our case, a folder of which name is composed of two written words unbound.

How we write in a Terminal a path or an expression that contains spaces - Unexpected argument

About the author

stealth

I am pleased to share my experiences with computers, mobile telephony and operating systems, develop web projects and provide the most useful tutorials and tips.
I like to play on iPhone, MacBook Pro, iPad, AirPort Extreme and on MacOS, iOS, Android and Windows operating systems.

Leave a Comment