3

Regarding linux cp same directory Similar files in another directory and rename?

 2 years ago
source link: https://www.codesd.com/item/regarding-linux-cp-same-directory-similar-files-in-another-directory-and-rename.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Regarding linux cp same directory Similar files in another directory and rename?

advertisements

I need copy some zip files(tea.zip, flower.zip, dog.zip) of "test" directory to "good" directory and rename them,I wish to use a command to complete the operation.

source: /home/test/,tea.zip, flower.zip, dog.zip

purpose: /home/good/,tea_ok.zip,flower_ok.zip, dog_ok.zip

1) How to write command at linux's ssh?

cp /home/test/[tea,flower,dog].zip /home/good/[tea,flower,dog]_ok.zip

Correct??

2) How to in bash?

Supplement:I need copy files,not move,and copy to different directory ,rename them.


It's intuitive to wirte this code.

mv /home/test/{tea,flower,dog}.zip  /home/{tea,flower,dog}_ok.zip

But it's wrong unluckily.

I think a consecutive command in shell can't fulfil your requirement.

You'd better write a simple shell script.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK