Linux Copy file giving replace in content

Asked

Viewed 41 times

0

how could it be done for me to copy a php file via shell script, but replace the contents of a variable?

Example: cat config-sample.php > config.php

<?php $senha="[dados_a_ser_substituido]";?>
  • And you cannot create a php terminal file with var_export(); to change the value of the variables?

  • Could, you know tell me what would be the syntax for this or where to get this information?

  • I usually use the sed command, in your case after copying the file try this command: sed -i 's/<?php $senha=".*;?>/<?php $senha="dados_que_eu_desejo";?>/g' config.php

  • Miguel It worked perfectly, there is some way to give 2 or more Places in the same line?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.