سؤال

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?

هل كانت مفيدة؟

المحلول

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
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top