The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Want to replace characters arndorff Shell Programming and Scripting 5 01-29-2008 04:05 PM
How to replace characters 7 through 14 of every line in a file jakSun8 Shell Programming and Scripting 9 12-13-2007 02:13 AM
Replace Special characters in a file solai UNIX for Dummies Questions & Answers 1 07-13-2006 11:36 AM
Replace characters in a string using their ascii value roops Shell Programming and Scripting 2 03-04-2005 01:51 AM
how to replace control characters using sed? hillxy Shell Programming and Scripting 5 10-16-2003 11:12 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-26-2006
lgardner17325 lgardner17325 is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 2
Replace Characters...

In a file, How do I replace a set number of characters in each line?

For example.... substitute the first 54 characters of each line with mv?

Thanks!
Lisa
  #2 (permalink)  
Old 10-26-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
'sed' is your friend - sed1liners
Code:
sed 's/^.\{54\}/mv/' myFile.txt

Last edited by vgersh99; 10-26-2006 at 05:23 PM..
  #3 (permalink)  
Old 10-26-2006
lgardner17325 lgardner17325 is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 2
Thank you so much.... it was exactly what I needed!!

Can I just ask.... is the "." considered a wildcard in this code?
  #4 (permalink)  
Old 10-26-2006
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Yes "." matches any character
  #5 (permalink)  
Old 10-26-2006
venu_nbk venu_nbk is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 33
Quote:
Originally Posted by vgersh99
'sed' is your friend - sed1liners
Code:
sed 's/^.\{54\}/mv/' myFile.txt
vgersh99

I have a doubt in this. If i am inside the file that is
vi myFile.txt.
Then how can I use the command, should I use the sed word?
  #6 (permalink)  
Old 10-26-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
no, but use the same 'substitute' expression in the vi 'command' mode.
  #7 (permalink)  
Old 10-26-2006
venu_nbk venu_nbk is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 33
Quote:
Originally Posted by vgersh99
no, but use the same 'substitute' expression in the vi 'command' mode.
Thanks,

could you please explain me what does this command mean?

:%s/crmrl01/crmpl01/g
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:59 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0