rsync delete single file from the target folder

Hi

We want to delete a single file from the destiantion directory using rsync. Is it possible to do this ? or Do we have any alternate approaches in rsync( for ex applying some filters ..etc)

For ex:
-----------------------------------------------
Source (Folder)
a.txt
b.txt

Dest(Folder)
a.txt
b.txt
c.txt
d.txt
------------------------------------------------
We want to delete only "c.txt" file from the destination not "d.txt".
Please share your thoughts.

afaik that's not possible, sure you could filter d.txt, but then it wont be transferred too

maybe you could exclude all --exclude='*' and include your file --include=c.txt, use rsync with --delete, and specify a "/" at the end of the folders, but use --dry-run to test

This may accomplish what you're trying to do, or at least point you in the right direction:

rsync -avz --exclude="d.txt" --delete --delete-during --progress --stats /dir1 /dir2

sending incremental file list
./
deleting c.txt

Number of files: 4
Number of files transferred: 0
Total file size: 0 bytes
Total transferred file size: 0 bytes
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 76
File list generation time: 0.002 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 88
Total bytes received: 15

sent 88 bytes  received 15 bytes  206.00 bytes/sec
total size is 0  speedup is 0.00

Hope this helps.

Thanks for your response. In this scenario its working fine.

But here we need to know the list of exclude files before. And also i noticed that it is not only performing deletion, if there are any updates/add in the source.. it is trying sync those files as well.

Is there any way to restrict the updates/add files? And also is there any option to exlucde all files except particular file for deletion?

I tried with the below option but it didn't work

rsync -avz --exclude="*" --include="c.txt" --delete --delete-during --progress --stats  /source/  /dest/

Please share your ideas....
Thanks you..

---------- Post updated at 05:56 PM ---------- Previous update was at 10:46 AM ----------

--include and --exclude options order makes difference.

I tried with below order

rsync -avz  --include="c.txt" --exclude="*"  --delete --delete-during --progress --stats /source/ /dest/

It works and the operation is only on the specified files.

I have one more question.. how can we achieve the same functionality for multiple files with different source and destination using single rsync command?(instead of running rsync multiple times).

Thanks !