How to rename files in a folder using the ls command output as a pipe ?

Posted by user1179459 on Super User See other posts from Super User or by user1179459
Published on 2012-10-18T03:05:01Z Indexed on 2012/10/18 5:09 UTC
Read the original article Hit count: 474

Filed under:
|
|

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

© Super User or respective owner

Related posts about linux

Related posts about command-line