LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   substitude the pattern in vi (https://www.linuxquestions.org/questions/linux-newbie-8/substitude-the-pattern-in-vi-632854/)

dina3e 04-03-2008 09:45 PM

substitude the pattern in vi
 
i just want to substitude the multiple pattenm, i mean two to three word simulteneously. i.e
linux==LINUX
UNIX==unics
kernel==core
i need this replacement in vi editor .

as we do :s/linux/LINUX/g
this is for only one pattern .similarly i need all three in one.It's great if you put the knowdge in vi editor.

Jerre Cope 04-03-2008 11:21 PM

Maybe you really want to use sed:

cat file1 | sed -e '1,$s/linux/LINUX/g' | \
sed -e '1,$s/kernel/core/g' >file2

vi is designed to give you quick visual feedback.

If you want to do programmatic large scale substitutions, try sed, awk, or perl.

dina3e 04-04-2008 08:28 PM

yha , i need what u did here. but u had done in two substitution in the solution . but i need to do such many substitution in lot of time so it's not benificial for me .

e.g i want to convert some of character in the file from capital to small letter. so what method you had mention is not give the complete solution .

djeikyb 04-04-2008 11:10 PM

I'll second Jerre. You might look into writing a short sed script that you can modify as needed.

grymoire.com has some excellent tutorials, including one on sed.

dina3e 04-09-2008 11:22 PM

it's really help full one
 
Quote:

Originally Posted by djeikyb (Post 3111285)
I'll second Jerre. You might look into writing a short sed script that you can modify as needed.

grymoire.com has some excellent tutorials, including one on sed.

This document is really intersting one..also very much help full
thanks


All times are GMT -5. The time now is 09:06 PM.