LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 04-03-2008, 10:45 PM   #1
dina3e
Member
 
Registered: Mar 2008
Location: Bangalore
Distribution: Enterprise Red Hat linux
Posts: 98

Rep: Reputation: 16
Smile 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.
 
Old 04-04-2008, 12:21 AM   #2
Jerre Cope
Member
 
Registered: Oct 2003
Location: Texas (central)
Distribution: ubuntu,Slackware,knoppix
Posts: 323

Rep: Reputation: 37
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.
 
Old 04-04-2008, 09:28 PM   #3
dina3e
Member
 
Registered: Mar 2008
Location: Bangalore
Distribution: Enterprise Red Hat linux
Posts: 98

Original Poster
Rep: Reputation: 16
Smile

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 .
 
Old 04-05-2008, 12:10 AM   #4
djeikyb
Member
 
Registered: Nov 2005
Location: California
Distribution: ubuntu 10
Posts: 162

Rep: Reputation: 33
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.
 
Old 04-10-2008, 12:22 AM   #5
dina3e
Member
 
Registered: Mar 2008
Location: Bangalore
Distribution: Enterprise Red Hat linux
Posts: 98

Original Poster
Rep: Reputation: 16
it's really help full one

Quote:
Originally Posted by djeikyb View Post
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
 
  


Reply

Tags
editor, vi


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
printing pattern match and not whole line that matches pattern Avatar33 Programming 13 05-06-2009 07:17 AM
pattern matching nadeemr Linux - Newbie 8 06-13-2007 12:05 PM
Http pattern rigel_kent Programming 10 05-06-2006 02:24 PM
using grep when the pattern contains a ! farmerjoe Programming 9 03-16-2005 12:04 AM
Pattern Recognition trbdk3 Linux - Software 1 01-27-2005 02:13 PM


All times are GMT -5. The time now is 03:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration