Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sed command edit multi files ( insert , replace line)

Tags:

linux

shell

sed

Ive 30 files named ( db01.php up to db30.php )

include this line

     require_once('config.php');

I want to add or replace it to be

    require_once('../new/config.php');

how to use sed to edit these 30 files at once

like image 882
Jecki Avatar asked Jan 24 '26 21:01

Jecki


1 Answers

sed -i 's/\(require_once(.\)\(config\.php.);\)/\1..\/new\/\2/' db*.php
like image 148
nosid Avatar answered Jan 27 '26 16:01

nosid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!