Reputation: 1405
I'm using LFTP to mirror some Git files to my server from a Docker image using a CI/CD Pipeline vendor. This works as expected but when using the mirror
command from LFTP, I need to exclude any kind of file starting with a dot, like so:
lftp -u $USERNAME, -e "[...] mirror [...] --ignore-time -x '/(\.\w*.*)/$' --exclude README.md [...]; exit" sftp://$HOST
But none of those are working, it just jumps out that -x
command and goes for the next one (e.g. --exclude README.md
).
I guess is not about using -x
or --exclude
since, from the docs:
mirror [OPTS] [source [target]]
[...]
-x RX, --exclude=RX exclude matching files
This ones didn't work either:
-x '/(\.\w*.*)/$'
-x /(\.\w*.*)/$
-x /(\.\w*.*)/
-x (\.\w*.*)
-x \.\w*.*
What is wrong then? Isn't that a valid regex for Bash?
Upvotes: 2
Views: 2043
Reputation: 1405
For some reason the only way that worked for me is to use $
at the end of the --exclude
regex, like so:
lftp -u $USERNAME, -e "[...] mirror [...] --exclude '^\..*$'[...]
Without the end-of-line delimiter it seems to not work at all, just ignores that --exclude
or -x
option and goes for the next one . Also, the regex must be wrapped in quotation marks (single or double).
Hope this helps someone :)
Upvotes: 2