Search code examples
regexunixrsync

Rsync file with regex


The folder in somehost is as following

/strbase/logs/service

Which has among many files the following file:

service.fix.20151109.log.gz

I want to use rsync to transfer this file to my local home directory, but I have to use a regex

^service\.fix\.20151109\.log\.gz$

This works according to regex101.com.

I tried the following command but nothing got transferred.

/usr/local/bin/rsync -a --bwlimit=1333 --include="^service\.fix\.20151109\.log\.gz$" --exclude="*" --rsync-path=/usr/bin/rsync somehostname:/strbase/logs/service ~

What am I missing?


Solution

  • Whilst it does not answer the original question of how to use rsync with a regex, to transfer the file service.fix.20151109.log.gz I used:

    /usr/local/bin/rsync -a --bwlimit=1333 --rsync-path=/usr/bin/rsync somehostname:/strbase/logs/service/service.fix.20151109.log.gz ~
    

    I took out the include and exclude.