0

I am using GNU/Linux and BASH shell,

What i wanted to do is in server is to

i need to be able to download the files stating with B* and D* and then rename them to ~B* and ~D*(same file name just ~ in-front)

i wrote following which works fine for the downloading part ideally i would like it to use ls command output as well but dont know how to do that.

cd inbox
get D*
get B*
ls B*|rename $0 ~B.* 
bye

Any idea ?

ideally what i would like to do is ls command to send the list of files one by one to the get command and then the once the get command is completed i want rename command executed renaming the server files

1 Answer 1

1

Do not execute this within your ftp session. Come out and execute it:

ls [BD]* | sed 's/.*/mv & ~&/' | sh
7
  • does anyone has any idea or any reference guide to what they mean in /s.*/ what is "s" i expect it a regular expression but i am used to php regular exp but this seems to be totally different... any link please for this ref ? i.e rename "s/ *//g" *.mp3 Oct 18, 2012 at 3:24
  • .* will match your entire file name and in the replacement section, mv command is generated. This mv command is executed using a shell.
    – Guru
    Oct 18, 2012 at 3:25
  • Can you expound upon this? Why is it so important to not execute within the ftp session. Oct 18, 2012 at 3:47
  • @KronoS my mistake, it can very well be part of the ftp session itself with an exclamation(!) in the beginning of ls.
    – Guru
    Oct 18, 2012 at 4:24
  • If it is executed in the ftp session (without the !) then it will attempt to do the rename on the remote server, or just fail. Oct 22, 2012 at 15:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .