Frage

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?

War es hilfreich?

Lösung

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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top