I am trying to mirror directories with lftp but I don't want to download filetypes that are notoriously large like .mp4 and .swf. But I am having trouble with the regex - and seeming like the exclude-glob too. Both of them download all files.

What I tried:

/usr/local/bin/lftp -u user,pass -e 'mirror -x ^(\.mp4|\.swf)$ $src $dest' ftp.host


/usr/local/bin/lftp -u user,pass -e 'mirror -X swf $src $dest' ftp.host


In the first case you have to quote the vertical bar (|), since inside lftp it is a special symbol too (also use double quotes to interpolate src and dest variables, quote backslash and dollar sign to prevent their interpretation by the shell):

/usr/local/bin/lftp -u user,pass -e "mirror -x '^(\\.mp4|\\.swf)\$' $src $dest" ftp.host

In the second case you have to use glob patterns, like this:

/usr/local/bin/lftp -u user,pass -e "mirror -X *.mp4 -X *.swf $src $dest" ftp.host

In any case I would recommend to test the mirror command by hand first and automate it later.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.