Artificial intelligent assistant

Search and replace sentence with spaces using sed command I am trying to use the sed command to replace some text in file. echo 'native_transport_port: 9042' | sed -E 's/native_transport_port:/\W9042/native_transport_port:9080' I get an error: `sed: 1: "s/native_transport_port ...": bad flag in substitute command: 'n'` I tried `echo 'native_transport_port: 9042' | sed -E 's/native_transport_port:\s9042/native_transport_port:\s9080'` But get an error: `sed: 1: "s/native_transport_port ...": unterminated substitute in regular expression` I am basically trying to search for native_transport_port and replace 9042 with 9080.

You need to finish the `s` command with a final `/`:


sed -E 's/native_transport_port:\s9042/native_transport_port:\s9080/'


While I'm at it, `\s` doesn't mean anything special in the replacement section, it becomes `s`; so you should do


sed -E 's/native_transport_port:\s9042/native_transport_port: 9080/'


or, if you want to reproduce the whitespace as-is,


sed -E 's/(native_transport_port:\s)9042/\19080/'


which re-uses the matched text in the replacement.

If your `sed` doesn't support Perl-style `\s`, you can match on space instead:


sed 's/native_transport_port: 9042/native_transport_port: 9080/'

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 1b5d80bf5acfeaa8ee006b138eaf7ba9