Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 04-07-2012
Registered User
 
Join Date: Dec 2006
Posts: 495
Thanks: 260
Thanked 1 Time in 1 Post
Making Changes to large file in vi

so i have a large file that has many lines in it.

i want to make changes (replace certain things) that are in a range of lines, but NOT the whole file.

how do i do this?

say for instance, if i want to change all the occurrences of the word "ramamama" to "ram cow welcome" in lines 9333 to 35000. How do i do this?

below is as far as i've gotten:


Code:
:%s~ramamama~ram cow welcome~g

Sponsored Links
    #2  
Old 04-07-2012
Registered User
 
Join Date: Jan 2012
Posts: 6
Thanks: 0
Thanked 2 Times in 2 Posts

Code:
:9333,35000s/ramamama/ram cow welcome/g

Sponsored Links
    #3  
Old 04-07-2012
Registered User
 
Join Date: Dec 2006
Posts: 495
Thanks: 260
Thanked 1 Time in 1 Post
Quote:
Originally Posted by keb0x80 View Post
Code:
:9333,35000s/ramamama/ram cow welcome/g


can the slashes be avoided?
    #4  
Old 04-07-2012
Registered User
 
Join Date: Jan 2012
Posts: 6
Thanks: 0
Thanked 2 Times in 2 Posts
If you're using vim you can replace the slashes with another character. I'm not sure in other versions of vi though.
The Following User Says Thank You to keb0x80 For This Useful Post:
SkySmart (04-07-2012)
Sponsored Links
    #5  
Old 04-08-2012
Registered User
 
Join Date: Dec 2006
Posts: 495
Thanks: 260
Thanked 1 Time in 1 Post
Quote:
Originally Posted by keb0x80 View Post
Code:
:9333,35000s/ramamama/ram cow welcome/g


i just tested it. unfortunately, it appears it isn't working.
Sponsored Links
    #6  
Old 04-08-2012
methyl methyl is offline Forum Staff  
Moderator
 
Join Date: Mar 2008
Posts: 6,388
Thanks: 286
Thanked 668 Times in 640 Posts
Please post what Operating System and version you are running and what Shell you are using.

Please post quantative figures for your file.
Exact size?
Number of records?
Largest record size?

And for your computer:
How much memory do you have fitted?


Quote:
can the slashes be avoided?
Why? There is no solidus in your strings.
Does the command work WITH the solidii?
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Making replicates of a file with part of a line randomized for each file Scatterbrain26 UNIX for Dummies Questions & Answers 1 08-10-2011 05:55 PM
Making Large Connection nodes for Graph anjas Shell Programming and Scripting 3 07-13-2009 05:20 AM
problem while making ftp of a large file rprajendran UNIX for Dummies Questions & Answers 1 05-28-2008 01:19 AM
making an iso file... asafronit SCO 5 03-08-2008 05:18 PM
sed : Making changes in the same file amol Shell Programming and Scripting 3 07-17-2002 06:50 AM



All times are GMT -4. The time now is 04:11 PM.