Why does the -i option/argument behave differently for sed and grep?

So when using the sed command in the terminal we have to write ‘-i’ in after sed to actually rewrite the file and change it. However, we use -i to specificy for the grep command that the search should be case insensitive. Why is -i used differently in these two instances. And further, how do we specifiy case sensitivity (or non-sensitivity) for sed?

These might be helpful:


-i when using the stream editor (sed) means you can edit the file in place
" sed writes output to standard output. Use -i to edit files in-place instead of printing to standard output"

-i in grep means ignore case distinctions when searching.


This also might be of use:

1 Like

So how would you use sed such that it was or wasn’t case sensitive?

  • grep is used for searching and pattern matching in files.

  • sed is an editor (that works like regex, I guess) that searches for text that you want to change in files.

To make the search pattern case-insensitive I believe you use the “I” (that’s a capital letter I (eye) not a lowercase l (el) or the pipe, “|” character).


If you have a Mac, OS, Catalina the capital letter “I” does not work:


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.