0

I have a file named servername_test_LINUX_test_test_2019-04-19.xls

I have to create multiple copies of this file, with the condition that server name should be changed in each file created

e.g.

original file-name:

servername_test_LINUX_test_test_2019-04-19.xls 

newly created files names should be like this:

servername_test_LINUX_test_test_2019-04-19.xls 
test_test_LINUX_test_test_2019-04-19.xls 
example_test_LINUX_test_test_2019-04-19.xls 

closed as unclear what you're asking by muru, Jeff Schaller Apr 30 at 9:58

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    What determines the new filenames? – Jesse_b Apr 18 at 19:20
  • the tool for the job is larry wall's rename (apt-get install rename). – ctrl-alt-delor Apr 18 at 19:49
  • DOTA@ that did not work.. to be more clear. i have .xls file.. like this servername_test_LINUX_test_test_2019-04-19.xls .... i have to create the same file 100 times with 100 diff server names. so the servername field should be changing for every new file created with the server list i have. ... from the script you have given.. i have created server_list file and inserted server names in it and executed it. rest all i kept same...my OS- redhat. ty – sanjay golla Apr 18 at 22:04
  • "i have created server_list file" please edit your question to include a minimal sample of this file – steeldriver Apr 18 at 22:27
  • Welcome to Stack Exchange. It would appear that you have accidentally created two accounts.  This will interfere with commenting, editing your own posts, and accepting an answer.  You should use the contact form and select “I need to merge user profiles” to have your accounts merged.  In order to merge them, you will need to provide links to the two accounts.  For your information, these are unix.stackexchange.com/users/347907/sanjay-golla and unix.stackexchange.com/users/347925/sanjay-golla. You’ll then be able to edit your question. – G-Man Apr 19 at 4:14
2

I don't know how we're deterministically determining servername (I'm just iterating through a space delimited list of servernames in $server_list), but here's maybe a skeleton you can work from:

fn='_test_LINUX_test_test_2019-04-19.xls'; for s in $server_list; do cp -a servername$fn $s$fn; done

Not the answer you're looking for? Browse other questions tagged or ask your own question.