V
V
Viktor Taran2021-03-15 10:06:33
bash
Viktor Taran, 2021-03-15 10:06:33

How to execute grep results in bash script?

grep  "^\$DB.*;" /home/bitrix/ext_www/site.ru/bitrix/php_interface/dbconn.php | sed 's/;//g'


conclusion
$DBType = "mysql"
$DBHost = "localhost"
$DBLogin = "site"
$DBPassword = 'pYa%W&cwsA]kK[QH'
$DBName = "dbcentre"
$DBDebug = false
$DBDebugToFile = false


Now I want to get these variables in my script
. How to make this output part of my script?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xibir, 2021-03-15
@shambler81

Something like this

eval `sed -rn 's/^\$(DB.+);$/\1/p' /home/bitrix/ext_www/site.ru/bitrix/php_interface/dbconn.php`

S
SOTVM, 2021-03-15
@sotvm

grep >> (add to the desired file) superduper PS
will
add to the end of the file
if you need "exactly where to shove", (beginning / end / instead of / between lines)
then gray or pearl,
first add the grep exhaust to the file,
only then execute it
PS
the question is clear, with a trick?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question