The shell script modifies the specified block of code in the code file

how to insert a line of code in a specified code block with commands such as sed , awk , and so on.

suppose you have a file hello.php , with the following contents:

  piplin  package, modify the  app/Providers/AppServiceProvider.php  file, and add \ URL::forceScheme ("https") to the code block of the method  function boot () ;  to enable https. The container itself is a php network server, and php components are already installed, so using php to do this is a better solution in this case. 

Mar.23,2021

this is more difficult to use sed, if you can accept the use of perl, java, python, it is much easier to write a corresponding script, although a little longer, but easier to maintain.


it's much easier to think of hello.php as a template,:

  • put placeholder in it for easy replacement; or
  • put it directly in the shell script in the form of herredoc, replace placeholder with variables, and control the contents of variables before using them
Menu