Move a remote file at an FTP prompt
Solution 1
I think it depends more on the client that you're using. Take a look at the client, lftp
. There's a good tutorial on using it here, titled: Unix: Flexibly moving files with lftp.
If you look through the help for lftp
you'll notice the command mv
.
$ lftp
lftp :~> help
!<shell-command> (commands) alias [<name> [<value>]] attach [PID]
bookmark [SUBCMD] cache [SUBCMD] cat [-b] <files> cd <rdir>
chmod [OPTS] mode file... close [-a] [re]cls [opts] [path/][pattern] debug [<level>|off] [-o <file>]
du [options] <dirs> exit [<code>|bg] get [OPTS] <rfile> [-o <lfile>] glob [OPTS] <cmd> <args> help [<cmd>]
history -w file|-r file|-c|-l [cnt] jobs [-v] kill all|<job_no> lcd <ldir>
lftp [OPTS] <site> ln [-s] <file1> <file2> ls [<args>] mget [OPTS] <files>
mirror [OPTS] [remote [local]] mkdir [-p] <dirs> module name [args] more <files>
mput [OPTS] <files> mrm <files> mv <file1> <file2> [re]nlist [<args>]
open [OPTS] <site> pget [OPTS] <rfile> [-o <lfile>] put [OPTS] <lfile> [-o <rfile>] pwd [-p]
queue [OPTS] [<cmd>] quote <cmd> repeat [OPTS] [delay] [command] rm [-r] [-f] <files>
rmdir [-f] <dirs> scache [<session_no>] set [OPT] [<var> [<val>]] site <site-cmd> source <file>
torrent [-O <dir>] <file|URL>... user <user|URL> [<pass>] wait [<jobno>] zcat <files> zmore <files>
Solution 2
Use the rename
command.
rename /a/myfile /a/b/myfile
I think most ftp clients use rename, not mv
like lftp (as in slm's answer).
Related videos on Youtube
Godson
Updated on September 18, 2022Comments
-
Godson over 1 year
I don't think it's possible but still I would like to ask if there is any command to transfer a remote file from one directory to other at an FTP prompt.
In more detail: I run
ftp
to a remote machine. I am at theftp
prompt, in the directory/a
. By mistake, I have uploaded a file (viaput
) to this directory, but that's the wrong directory. I want to move the file from this directory to/a/b
on the remote machine. Can I do this from the FTP prompt?I have checked and I cannot telnet to that machine. If this is impossible in FTP, is there another way I can move the file and avoid having to transfer it again?
-
Alessio over 10 yearsThis works but note that you need write permission on both the source directory and the destination directory. and if the file already exists in the target directory, you also need write permission on it.
-
Godson over 10 yearsGreat slm, thanks for mentioning the command
mv
for the purpose. -
slm over 10 years@Ravi - Glad this solved your problem, please mark this as the accepted answer so that others know your issue has been resolved.
-
Godson over 10 yearsI hope the way I marked this as the accepted answer by clicking on the "V" symbol is fine. Thank you slm for your assistance
-
slm over 10 years@Ravi - yup, that's how you do it. Thanks for the questions!