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.
press CTRL-D to end your input. This is the right answer. Ctrl-D is the canonical way to terminate keyboard stdin in any shell command.
We have been using read “read –r” while reading from another file as other than standard input. On the other hand, using “-u” as bash-specific, the standard output from the user in the terminal. Here, the “name” is the text or content of the file “script.sh”. The option “-p” is used to “read”.
Bash read Built-in read is a bash built-in command that reads a line from the standard input (or from the file descriptor) and split the line into words.
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With