linux: which is the right way to copy folder? [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I want to copy folder ajax_search, path: /home/thejobco/public_html/JCCore/ajax_search/ to be inside this foler:/home/thejobco/public_html/demo/typo3conf/ext/, should I run command this way:
cp -r /home/thejobco/public_html/JCCore/ajax_search/ /home/thejobco/public_html/demo/typo3conf/ext/
or
cp -r /home/thejobco/public_html/JCCore/ajax_search/ /home/thejobco/public_html/demo/typo3conf/ext
I am familiar with window, but not unix/linux, I put / after ajax_search, I know this way ajax_search/, shows ajax_search is a folder, but i do not know should i put / after ext or not? can anyone explain to me which is the right way to copy folder? thanks

With cp, if the destination directory already exists and you do not use a trailing slash on the source-dir, then you are actually putting a copy of source-dir inside dest-dir; this can be a problem when you forgot that the destination directory already exists.
You should include the trailing slash, to make it obvious to cp that you are trying to copy a directory name to a new directory name, and not copy the directory into an existing one, if it exists.

Related

How do I remove a directory with the name of '--' [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
A badly-written script created a directory named '--' (including the single quotes) in my home directory.
When I cd to that directory, I am brought back to my home directory.
I'd like to remove that item, but cannot figure out how to do it. Escaping some or all of the characters in the directory name, returns No such file or directory.
rmdir \'--\' should do the trick
simply type the following:
rm -rf \'--

How to change directory of a file in ubuntu [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I have python file in by ubuntu virtual machine's home directory. Is there any way I can move it to another directory instead of copying the entire code and then making a file in the directory and then pasting and saving it as a new file.
Can you use the copy (cp) command?
cp <file_to_copy> <location_to_copy_to>
That's a very silly question.
Just copy/cut the file and move it to the required directory. No need to copy the code and the creating a new file in another directory you can do this manually ( by right clicking, cut ,paste) or via terminal by just typing mv [Path of file] [The destination or cp [Path of file] [Destination]

Why not "mv -r" in Linux bash? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
Well, I know you have to use -r with cp and rm when dealing with directories. It makes this job recursively (meaning it coping and removing all starting with things inside).
But why you dont do "mv -r" when moving / renaming directories?
Directories are just collections of pointers to locations of files on the filesystem. When you move a directory you are updating the file pointers of the new and old parents to contain/remove the one you moved. Thus, child file pointers inside do not require recursive action as none of the pointer locations have actually changed for them.
EDIT: I've just found a much more detailed answer on Unix & Linux StackExchange that will help explain this further.
https://unix.stackexchange.com/questions/46066/why-unix-mv-program-doesnt-need-r-recursive-option-for-directories-but-cp-do
For every move, new location is needed.
If one wants to move all files under directory alongwith the directory, just move the directory which is recursive.

windows equivalent of ./ (current directory) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
On Linux when I want to execute some file and use relative path.
For example I want to do something like this:
cd c:\windows
c:\windows>./System32/ipconfig.exe
However what I get is an error message telling me that "." has not been found.
A period denotes the current directory in Windows.
For your example you would use the following:
c:\> cd c:\windows
c:\Windows> .\System32\ipconfig.exe
Alternately, you could forego the .\ and do it like this:
c:\Windows> System32\ipconfig.exe
Use the correct slash marks and you should be good. Windows uses backslashes as the directory symbol instead of the forward slash.
The only caveat to this is if you have to change drive letters. The cd command will change the working directory, but not the drive. To change drives use [drive letter][colon]:
C:\Windows>cd P:\XenApp\Utils
C:\Windows>P:
P:\XenApp\Utils>

Replace all files except one with rsync [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I'm currently using rsync as follows
rsync -az --delete ...
What option can I use with rsync to replace all destination files that already exist except for one specific file that should not be replaced if already exists? Sure, if the file doesn't exist at the destination, it should be put there.
I don't know whether it is possible in one invocation, but you could call rsync twice:
rsync ... --ignore-existing file dest
Now the file is put there if it didn't exist before.
rsync ... --exclude file src dest
Now all the other files are handled as usual, except for the one excluded file.

Resources