LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-12-2005, 01:41 AM   #1
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
some vim help pelase.


i was attempting to update my yum.conf for CentOS 4 from the 4.1 to 4.2 using vim.

IIRC and if i understand vi correctly i could type the following to find and replace all 4.1 with 4.2.


:s/4.1/4.2:g

and that should swap all of the 4.1 with 4.2 globally in the file. i was getting an error pattern 4.1 not found, yet it clearly highlighted all of the 4.1 in the file. so what was i doing wrong?
 
Old 12-12-2005, 03:17 AM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
I'm probably wrong, but I think you need:
Code:
:s/4.1/4.2/g
 
Old 12-12-2005, 03:47 AM   #3
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
What you should have done is installed the centos-release rpm for 4.2 and that would have done it for you. To upgrade you would then just run "yum upgrade".
 
Old 12-12-2005, 08:09 AM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
The vi substitution for the whole doc should be something like this:
:%s/4.1/4.2
 
Old 12-12-2005, 09:07 AM   #5
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
You need to escape the dots.
. = any character, so will change 401 into 4.2

safer is:

:g/4\.1/s//4\.2/gc will ask for confirmation

or in perl:

perl -pi.bak 's/4\.1/4\.2/g' <filename>

will do it and make <filename>.bak

but reddazz is probly more correct.
 
Old 12-12-2005, 10:20 AM   #6
prabuayyappan
Member
 
Registered: Sep 2005
Location: Coimbatore
Distribution: Prabuayyappan
Posts: 32

Rep: Reputation: 15
:%s/4\.1/4\.2/g

This will replace the 4.1 with 4.2 globally.To ask for confirmation add c

To get more info on vi

http://www.math.mcgill.ca/lebaron/ru...00000000000000
 
Old 12-12-2005, 12:19 PM   #7
amitsharma_26
Member
 
Registered: Sep 2005
Location: New delhi
Distribution: RHEL 3.0/4.0
Posts: 777

Rep: Reputation: 31
Quote:
Originally Posted by prabuayyappan
:%s/4\.1/4\.2/g

This will replace the 4.1 with 4.2 globally.To ask for confirmation add c

To get more info on vi

http://www.math.mcgill.ca/lebaron/ru...00000000000000
Thanks prabuayyappan for the link.
 
Old 12-12-2005, 03:33 PM   #8
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
thanks all of you for the great info and help.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
encryption with Vim (vim -x) mikshaw Linux - Software 2 03-07-2007 09:00 AM
Im not in my network workgroup, help pelase!!! haora Linux - Networking 3 06-29-2005 01:37 PM
how do you play mpeg files on redhat 9?? pelase explain it simple because i am a noob qod Linux - Newbie 8 10-25-2003 09:46 AM
Need Help pelase!! DaKid Linux - Networking 5 03-17-2003 04:42 PM
Pelase Help Me! Russianbean Linux - General 1 09-27-2001 08:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:38 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
Open Source Consulting | Domain Registration