Frage

Ich möchte in einem Absatz eine Zeichenfolge hinzufügen

das ist:

$rcmail_config['default_host'] = '';

zu

$rcmail_config['default_host'] = 'abcdef';

Ist es mit SED möglich?

War es hilfreich?

Lösung

Machen:

sed -i "s/\$rcmail_config\['default_host'\] =.*/\$rcmail_config['default_host'] = 'abcdef';/" /your.file

Es wird nur die Zeile ersetzen und Ihre Daten unabhängig von zuvor festlegen.

Andere Tipps

sed -e "/\$rcmail_config/s/'';$/'abcdef';/" sollte tun, was du willst.

> echo -e "foo = '';\nbar = '';\n\$rcmail_config['default_host'] = '';"
foo = '';
bar = '';
$rcmail_config['default_host'] = '';

> echo -e "foo = '';\nbar = '';\n\$rcmail_config['default_host'] = '';" | sed -e "/\$rcmail_config/s/'';$/'abcdef';/"
foo = '';
bar = '';
$rcmail_config['default_host'] = 'abcdef';
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top