AWK pipe output to SED to replace -


i'm trying replace string using awk pipe out sed

grep pdo_user /html/data/_default_/configs/application.ini | awk '{print $3}' | sed -i 's/$1/"username"/g' /html/data/_default_/configs/application.ini 

but found string not replaced

output

grep pdo_user /html/data/_default_/configs/application.ini | awk '{print $3}'

is

"root"

any tips on that?

i suggest use awk , mv:

awk '/pdo_user/ && $3=="\"root\"" {$3="\"username\""}1' /path/to/application.ini > /path/to/application.tmp mv /path/to/application.tmp /path/to/application.ini 

Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -