How do I get sed to read from standard input?
use the --expression option
grep searchterm myfile.csv | sed --expression='s/replaceme/withthis/g'
If you are trying to do an in-place update of text within a file, this is much easier to reason about in my mind.
grep -Rl text_to_find directory_to_search 2>/dev/null | while read line; do sed -i 's/text_to_find/replacement_text/g' $line; done
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}'