Replace all files except one with rsync [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 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.

Related

Renaming file with date using mv command [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 8 months ago.
Improve this question
How to change the filename from file.txt to renaming it to be file_may_20_2020.txt
using mv command?
I have used
mv file file_(`date`).txt
I still don't know how to put a command inside another command
Use either
mv file file_"`date +"%B_%d_%y"`".txt
or
mv file file_"$(date +"%B_%d_%y")".txt
mv file file_"$(date +"%B_%d_%y")".txt
What you put inside the $ is like a template string and its value is placed in the string

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 \'--

Linux where does zip place the newly created zip file? [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 5 years ago.
Improve this question
Looking to zip up a folder on my linux box ie zip -r9 test /var/www/html/ where does that resulting test.zip file end up? in my pwd? I still want to leave the contents of /var/www/html intact.
Yes, it creates zip in your current working directory.
True is that you are free to specify relative or absolute paths like you wish.
zip test.zip path/to/files
will place test.zip in the current working directory.
zip /foo/bar/test.zip path/to/files
will place test.zip in /foo/bar

Is there an scp variant of mv command? [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 8 years ago.
Improve this question
I am writing a script that will move files from a local system to a remote system. It must do so through an encrypted channel like ssh. What is the best way to do this? I can perform this in two steps like:
scp *.jpg user#ip:
rm *.jpg
But, that is not an atomic process (like mv is for a local filesystem). If the copy fails I will no longer have the local copies either. How can I script this to make sure the local files only get removed if the copy succeeds?
You could use rsync with --remove-source-files:
rsync -avz --remove-source-files /local/dir/*.jpg user#ip:/remote/dir
An other solution, for launch in one time
scp /path/src/*.jpg user#host:/path/dst/ && rm /path/src/*.jpg

linux: which is the right way to copy folder? [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 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.

Resources