Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I need a file to stay in the same location but also move it to a different location.
What am I doing wrong?

cp RubyTest.sublime-settings \
    ~/Library/Application Support/Sublime\ Text\ 2/Packages/User
share|improve this question

migrated from stackoverflow.com May 17 '12 at 14:15

This question came from our site for professional and enthusiast programmers.

3  
You aren't escaping the space between Application and Support. –  Gabe May 17 '12 at 4:31
    
I need it to stay in the same location but also move it to a different location @ Gabe thank you –  Victoria May 17 '12 at 4:31
2  
Victoria: The word "copy" means to create a second file in another location with the same contents, leaving the original file as-is; the word "move" means change the location of a file so it is in the new place instead of the original place. You can't have both. –  Gabe May 17 '12 at 4:41
add comment

2 Answers 2

up vote 3 down vote accepted

Put quotes around the path, but leave the ~ out of the quotes:

cp RubyTest.sublime-settings \
    ~/"Library/Application Support/Sublime Text 2/Packages/User"

Within quotes, you can't use the ~ syntax, but you can use the longer $HOME instead:

cp RubyTest.sublime-settings \
    "$HOME/Library/Application Support/Sublime Text 2/Packages/User"
share|improve this answer
add comment

Stay in the same location and move to a different location is impossible - unless you are taling about a symbolic link.

cp will make a copy of your file to a new location without modifying the original version.

As the comment says, your big problem is spaces in file names. Wrap your arguments to cp in quotes. The ~ character won't expand to your home directory if it's in quotes; either use $HOME instead (which is expanded in double quotes) or leave the ~ outside the quotes.

cp "RubyTest.sublime-settings" \
    "$HOME/Library/Application Support/Sublime Text 2/Packages/User"
cp "RubyTest.sublime-settings" \
    ~/"Library/Application Support/Sublime Text 2/Packages/User"
share|improve this answer
    
There are hard links too. –  ams May 17 '12 at 14:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.