How do I get sed to read from standard input? [duplicate]

I am trying

grep searchterm myfile.csv | sed 's/replaceme/withthis/g'

and getting

unknown option to `s'

What am I doing wrong?

Edit:

As per the comments the code is actually correct. My full code resembled something like the following

grep searchterm myfile.csv | sed 's/replaceme/withthis/g'
# my comment

And it appears that for some reason my comment was being fed as input into sed. Very strange.


use the --expression option

grep searchterm myfile.csv | sed --expression='s/replaceme/withthis/g'

use "-e" to specify the sed-expression

cat input.txt | sed -e 's/foo/bar/g'

To make sed catch from stdin , instead of from a file, you should use -e.

Like this:

curl -k -u admin:admin https://$HOSTNAME:9070/api/tm/3.8/status/$HOSTNAME/statistics/traffic_ips/trafc_ip/ | sed -e 's/["{}]//g' |sed -e 's/[]]//g' |sed -e 's/[\[]//g' |awk  'BEGIN{FS=":"} {print $4}'