If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > How do I change string x*y to a*b

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-20-05, 08:56
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
How do I change string x*y to a*b

How do I change string x*y to a*b
Where * can be any number of characters
e.g.
# cat f1
1/2/2004
15/2/2004
1/11/2004
15/11/2004
1/2/2005
15/2/2005
1/11/2005
15/11/2005

change "15/<any chars>/2005" to "20/<the any chars>/2006" resulting in
1/2/2004
15/2/2004
1/11/2004
15/11/2004
1/2/2005
20/2/2006
1/11/2005
20/11/2006

The closest I get is:
# cat f1 | sed 's!15/.*/2005!20/&/2006!'
1/2/2004
15/2/2004
1/11/2004
15/11/2004
1/2/2005
20/15/2/2005/2006
1/11/2005
20/15/11/2005/2006
Reply With Quote
  #2 (permalink)  
Old 12-20-05, 09:41
vgersh99 vgersh99 is offline
Registered User
 
Join Date: Apr 2004
Location: Boston, MA
Posts: 325
Code:
sed 's#^\(15\)\(/.*/\)\(2005\)#20\22006#' f1
__________________
vlad
+-----------------------+
| #include <disclaimer.h> |
+-----------------------+
Reply With Quote
  #3 (permalink)  
Old 12-21-05, 01:51
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
Thank you
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On