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
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3766d-4061a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3766d-4061a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?