我有以下文件:
蒙戈
'mongodb' => [
'driver' => 'mongodb',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', 27017),
'database' => env('DB_DATABASE'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'options' => [
'database' => 'admin' // sets the authentication database required by mongo 3
]
],
和sed命令:
sed -i "/'connections' => \[/a \ "$(cat mongo)" \\" /app/config/database.php
所以我想在字符串后面插入mongo
文件的内容:
'connections' => [
搜索很好,sed找到了字符串,但没有正确获取文件mongo
的内容。
我收到以下错误:
sed: can't read 'mongodb': No such file or directory
sed: can't read =>: No such file or directory
sed: can't read [: No such file or directory
sed: can't read 'driver': No such file or directory
sed: can't read =>: No such file or directory
sed: can't read 'mongodb',: No such file or directory
sed: can't read 'host': No such file or directory
答案 0 :(得分:1)
这可能适合你(GNU sed):
sed -i '/'\''connections'\'' => \[/r mongoFile' file
在connections
地址后阅读mongoFile。