Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I recursively ftp only certain file types from a linux server using the command line?

Tags:

I want to download only .htm or .html files from my server. I'm trying to use ncftpget and even wget but only with limited success.

with ncftpget I can download the whole tree structure no problem but can't seem to specify which files I want, it's either all or nothing.

If I specify the file type like this, it only looks in the top folder:

ncftpget -R -u myuser -p mypass ftp://ftp.myserver.com/public_html/*.htm ./local_folder

If I do this, it downloads the whole site and not just .htm files:

ncftpget -R -u myuser -p mypass ftp://ftp.myserver.com/public_html/ ./local_folder *.htm

Can I use ncftp to do this, or is there another tool I should be using?

like image 510
john ryan Avatar asked Jul 31 '09 22:07

john ryan


People also ask

What is MPUT command in FTP?

The MPUTcommand transfers one or more files matching the given filespec from the PC to the FTP server. You can use wildcards to transfer multiple files.

What are FTP commands?

The ftp command uses the File Transfer Protocol (FTP) to transfer files between the local host and a remote host or between two remote hosts. Remote execution of the ftp command is not recommended. The FTP protocol allows data transfer between hosts that use dissimilar file systems.


1 Answers

You can do it with wget

wget -r -np -A "*.htm*" ftp://site/dir

or:

wget -m -np -A "*.htm*" ftp://user:pass@host/dir

However, as per Types of Files:

Note that these two options do not affect the downloading of HTML files (as determined by a .htm or .html filename prefix). This behavior may not be desirable for all users, and may be changed for future versions of Wget.

like image 159
Oleksandr Tymoshenko Avatar answered Oct 05 '22 14:10

Oleksandr Tymoshenko