F
F
Free0wl2021-09-13 15:12:36
SSH
Free0wl, 2021-09-13 15:12:36

How to remotely execute sed with quotes?

how to replace part of the string after "$config['product_name'] = ".
need to do the replacement remotely: ssh [email protected] "sed ...."

# cat 4del/file4del.php
$config['enable_spellcheck'] = false;
$config['language'] = 'ru_RU';
$config['create_default_folders'] = true;

// Branding
$config['product_name'] = 'здесь может быть что угодно';
//$config['skin_logo'] = null;


Let's say I know how to replace, albeit not beautifully, but still:
sed "s/^\$config\['product_name'\] = .*/\$config\['product_name'\] = 'My Company Webmail';/"

, but how to escape quotes for ssh?
Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Taran, 2021-09-13
@shambler81

Here I wrote how to screen tricky characters in gray

sed -i 's/\x24config\[\x27product_name\x27\] = \x27true\x27\x3B/\x24config\[\x27product_name\x27\] = \x27false\x27\x3B/' /etc/lalala/lala.conf

View example
Second part of the question
ssh [User_Name]@[Rremote_Host_Name or IP] [Command or Script]

Before changing, you can test instead of -i, put -e will output the result to the terminal
Thank you cap the issue is resolved

S
Saboteur, 2021-09-13
@saboteur_kiev

you can just like that
'\''
To simplify, by the way, when searching for a string, you can replace special characters simply with a dot:

ssh [email protected] "sed 's/^.config..product_name.*/\$config['\''product_name'\''] = '\''что угодно'\''/' a.txt"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question