Techware Labs Header

Forums have moved

See this announcement for more details, or just go directly there.

  #1  
Old 02-13-2002, 07:50 PM
Keefe Keefe is offline
Administrator
 
Join Date: May 2002
Location: Wisconsin
Posts: 2,337
Send a message via ICQ to Keefe Send a message via AIM to Keefe Send a message via MSN to Keefe Send a message via Yahoo to Keefe
Default Linux Command Question

I want to replace every occurance of with in every file in a specific folder.

What linux command could i use to do this?

Thanks

Keefe
__________________
It's crazy I'm thinking, just knowing that the world is round.
-http://www.techwarepc.com/ - The Technology Experts
Reply With Quote
  #2  
Old 02-22-2002, 07:33 PM
wizbones wizbones is offline
Golden Techie
 
Join Date: Sep 2001
Location: Stayton, OR
Posts: 699
Send a message via Yahoo to wizbones
Default Re: Linux Command Question

Oh it's like on the tip of my tougue but I can't remember the actual command.

What I use is homesite from http://www.allaire.com You can open several web pages at a time and replace the text or portion of text in every page in one or two clicks.

If I can remember the vi command I'll definately let you know.
__________________
Wizbones PC
http://www.wizbonespc.com
--------------------------------------------------------
The Maximum Effective Range of an Excuse is Zero point Zero Meters!
Reply With Quote
  #3  
Old 02-22-2002, 07:42 PM
wizbones wizbones is offline
Golden Techie
 
Join Date: Sep 2001
Location: Stayton, OR
Posts: 699
Send a message via Yahoo to wizbones
Default Re: Linux Command Question

Ok,

Phew braincell is smoking now:

Here goes

Open the file to edit in vi

To replace Do this ...
pattern1 with pattern2 :s/pattern1/pattern2 on the same line

every occurrence of pattern1 :g/pattern1/s//pattern2/g with pattern2

You may run into trouble with the characters in the text you're trying to change I'm not sure. I would make a copy of a file first and practice on that.

I'll see if I can dredge up a better way to so rather than file by file as well.

Cheers
__________________
Wizbones PC
http://www.wizbonespc.com
--------------------------------------------------------
The Maximum Effective Range of an Excuse is Zero point Zero Meters!
Reply With Quote
  #4  
Old 02-22-2002, 07:52 PM
wizbones wizbones is offline
Golden Techie
 
Join Date: Sep 2001
Location: Stayton, OR
Posts: 699
Send a message via Yahoo to wizbones
Default Re: Linux Command Question

Last post I promise,

You can open several files in vi at once but you'll still have to switch from one to the other to make your replacement. For example:

You open test.html and test1.html by typeing in
vi test.html test1.html

You now have both files open and are viewing test.html

Once you've replaced your text as noted in above post type :wq to save your changes and then :n to switch to the next one and so on. Kinda a pain but it works.

I still think the easiest solution is Homesite but what ever works best for you is what's important. Just tryin to help out.

Later
__________________
Wizbones PC
http://www.wizbonespc.com
--------------------------------------------------------
The Maximum Effective Range of an Excuse is Zero point Zero Meters!
Reply With Quote
  #5  
Old 02-22-2002, 07:55 PM
wizbones wizbones is offline
Golden Techie
 
Join Date: Sep 2001
Location: Stayton, OR
Posts: 699
Send a message via Yahoo to wizbones
Default Re: Linux Command Question

Alright I lied,

The text you want to replace vi wont work, because of the characters involved, so hey, go check out and download the eval of Homesite I think you'll find it's a cinch to learn, it's like a glorified notepad editor with super extra's  ;D

At we all learned a few new tricks in vi huh?

Gone for real this time  :-X
__________________
Wizbones PC
http://www.wizbonespc.com
--------------------------------------------------------
The Maximum Effective Range of an Excuse is Zero point Zero Meters!
Reply With Quote
  #6  
Old 02-22-2002, 08:49 PM
Keefe Keefe is offline
Administrator
 
Join Date: May 2002
Location: Wisconsin
Posts: 2,337
Send a message via ICQ to Keefe Send a message via AIM to Keefe Send a message via MSN to Keefe Send a message via Yahoo to Keefe
Default Re: Linux Command Question

I figured out a way to do it.

I searched on google and found a small, one line, perl script that will open every file, search + replace, and then make a back up of the file.  I do not have the syntax right here but when I find it I will definetly post it for all to see.

keefe
__________________
It's crazy I'm thinking, just knowing that the world is round.
-http://www.techwarepc.com/ - The Technology Experts
Reply With Quote
  #7  
Old 02-23-2002, 01:59 PM
wizbones wizbones is offline
Golden Techie
 
Join Date: Sep 2001
Location: Stayton, OR
Posts: 699
Send a message via Yahoo to wizbones
Default Re: Linux Command Question

Oh sure,

After I scrap my braincell you leave a tease   in place  

I'd like to use the script myself, so when you find it please do post it.

Thanks.
__________________
Wizbones PC
http://www.wizbonespc.com
--------------------------------------------------------
The Maximum Effective Range of an Excuse is Zero point Zero Meters!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 01:51 AM. Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Forum style by ForumMonkeys.