Tuesday, March 1, 2022

Insert a new line at the beginning of a file

 Here's a way to add a line to the beginning of a file:


sed -i '1s!^!set timing on\n set time on\n set echo on\n!' batch1.sql_bkp

find . -type f -name '*.sql' -exec sed -i '1s!^!set timing on\n set time on\n set echo on\n!' {} \;


sed -i '1s/^/line_to_be_added\n/' file

Then, you could use the code above with find to achieve your ultimate goal:

find . -type f -name '*.js' -exec sed -i '1s/^/line_to_be_added\n/' {} \;

No comments:

Post a Comment

Upgrading Oracle E-Business Suite Release 12.2 with Oracle Database 19c to 23ai on Oracle Exadata Database Service on Dedicated Infrastructure or Cloud@Customer

  1.1 Carry Out Performance Evaluation in a Test Environment When upgrading your Oracle E-Business Suite database, it is essential to ensure...