Question

Basically I want to do the following replacement using vi:

Apple->Orange
apple->orange
APPLE->ORANGE

Is there any way to do it in one line?

Was it helpful?

Solution

You can use sed command

$ cat os.txt
BEST
UNIX
Unix
uNiX

Sed supports "i" or "I" for "case insensitive" search and replacement
$ sed 's/unix/BEST/i' os.txt
BEST
BEST
BEST
BEST

If you need to use vi try this command

1,$ s/apple/orange/gI
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top