Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how does unix handle full path name with space and arguments?

Tags:

How does unix handle full path name with space and arguments ?
In windows we quote the path and add the command-line arguments after, how is it in unix?

 "c:\foo folder with space\foo.exe" -help 

update:

I meant how do I recognize a path from the command line arguments.

like image 538
CiNN Avatar asked Sep 08 '08 21:09

CiNN


People also ask

How do you handle a filename with space in Unix?

There are two main ways to handle such files or directories; one uses escape characters, i.e., backslash (\<space>), and the second is using apostrophes or quotation marks. Using backslash can be confusing; it's easy and better to use quotation marks or apostrophes.

Can Unix file names contain spaces?

It is said that on Unix and Linux in general, you should avoid having spaces in a filename of a file (ordinary file, dir, link, device file, ...).

Can Linux paths have spaces?

In the Linux operating system, we can run commands by passing multiple arguments. A space separates each argument. So, if we give the path that has a space, it will be considered two different arguments instead of one a single path.


1 Answers

You can either quote it like your Windows example above, or escape the spaces with backslashes:

 "/foo folder with space/foo" --help  /foo\ folder\ with\ space/foo --help 
like image 143
Paige Ruten Avatar answered Oct 20 '22 23:10

Paige Ruten