FTP – How to upload/download or delete directories recursively
The standard FTP program doesn’t support recursive operations on directories. The ncftp command supports recursive operations. This is very useful if your web hosting supports only FTP transfer.
First of all, check if ncftp command is already present in your Linux system.
[neo@techpulp ~]# ncftp bash: ncftp: command not found [neo@techpulp ~]#
If it is not present, then install appropriate package using “yum“.
[root@techpulp ~]# yum -y install ncftp
The following shows how to use ncftp to use a specific login instead of anonymous login.
[neo@techpulp ~]# ncftp -u neo liz.techpulp.com NcFTP 3.2.2 (Aug 18, 2008) by Mike Gleason (http://www.NcFTP.com/contact/). Connecting to 127.0.0.1... (vsFTPd 2.0.7) Logging in... Password requested by 172.16.178.161 for user "neo". Please specify the password. Password: ****** Login successful. Logged in to liz.techpulp.com. ncftp /home/neo > quit [neo@techpulp ~]#
At ncftp prompt, you can use typical FTP commands like ls, mkdir, get, put, mget, mput, del etc. However it supports -R option along with “put“, “get” and “rm” command for recursive operation on directories.
To download a remote directory recursively, use “get -R” option command with the directory.
ncftp /home/neo > get -R remotedir1
To upload a local directory recursively, use “put -R” option command with the directory.
ncftp /home/neo > put -R localdir1
To delete a remote directory recursively, use “rm -R” option command with the directory.
ncftp /home/neo > rm -R remotedir1
You can also use GUI tools like FileZilla, gFTP etc to do the same operations.