I want to use
ln -s $PWD ~/mylinkname
But the problem I'm facing is that my current path has space (therefore ln cannot execute correctly).
I believe the solution should be simply but I searched over cannot find answer.
Do you know how to solve this problem?
Thanks a lot.
Also try using the Grave Accent Character (`) PowerShell uses the grave accent (`) character as its escape character. Just add it before each space in the file name. (You'll find this character above the Tab key and below the Esc key on your keyboard.)
The shell will interpret that backslash as an escape of the space. The result will be that the command will not break the argument. The other way to escape space in a path is to enclose the path in quotes, which indicates to the executable that everything between the quotes is one argument.
In a bash script, we can escape spaces with \ .
Well, there are two approaches: Using escape character, i.e., “\<space>” Using apostrophes or quotation marks.
If your argument has spaces, it will treat each space-delimited portion as a separate argument.
To prevent this, quote any arguments that have spaces, eg:
ln -s "$PWD" "$HOME/my link name with spaces"
If the filename has quotes, you can also escape it with a backslash
ln -s "$PWD" "$HOME/my link name with spaces and this quote\""
Instead of $HOME, you can use:
ln -s "$PWD" ~/"my link name with spaces"
ln -s "$PWD" "$HOME/mylinkname"
should do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With