'when file name has space, how to use variable in script? [duplicate]
I want to open a application using shell script.
But! when file name has space, script read this as two files.
1 path=/Applications
2 program=/Google Chrome.app
3 open $path$program
it's not working...
when I use alias like these...
program="/Google Chrome.app" or
program=/Google\ Chrome.app or
program="/Google\ Chrome.app"
shell cognized two files like this
"The files /Applications/Google and /current_dir/Chrome.app do not exist."
How I fix that? please give me your teaching 🧐
Solution 1:[1]
You can wrap your variables in quotes. So what you can do is:
path=Applications
program="Google Chrome.app"
open /$path/$program
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | LinFelix |
