OT: Calling unix experts, Need "vi" assistance |
|
Porsche, and the Porsche crest are registered trademarks of Dr. Ing. h.c. F. Porsche AG.
This site is not affiliated with Porsche in any way. Its only purpose is to provide an online forum for car enthusiasts. All other trademarks are property of their respective owners. |
|
OT: Calling unix experts, Need "vi" assistance |
Rusty |
Aug 9 2004, 09:44 PM
Post
#21
|
Wanted: Engine case GA003709 Group: Admin Posts: 7,941 Joined: 24-December 02 From: North Alabama Member No.: 6 Region Association: Galt's Gulch |
Thanks guys! It's morning here now... I'm going to give it another shot!
-Rusty (IMG:style_emoticons/default/coffee.gif) |
Gint |
Aug 9 2004, 10:05 PM
Post
#22
|
Mike Ginter Group: Admin Posts: 16,075 Joined: 26-December 02 From: Denver CO. Member No.: 20 Region Association: Rocky Mountains |
Here's an even shorter version:
sed -e 's/BA0..../BAO1234/g' > newfilename BTW - There is almost always at least 14 different ways to do the same thing in Unix. Pick one you like the best and go with it. Another thing - I finally met Brad Mayeur Friday night. Told him you said "Hi." Rack time... |
Root_Werks |
Aug 10 2004, 11:53 AM
Post
#23
|
Village Idiot Group: Members Posts: 8,321 Joined: 25-May 04 From: About 5NM from Canada Member No.: 2,105 Region Association: Pacific Northwest |
Me thinks Gint wins the prize for this one! (IMG:style_emoticons/default/biggrin.gif) (IMG:style_emoticons/default/boldblue.gif)
|
bperry |
Aug 10 2004, 12:35 PM
Post
#24
|
Lurker Group: Members Posts: 477 Joined: 16-February 04 From: Dallas, Tx Member No.: 1,661 |
Man its been a while but I love vi and regular expressions.
We used to have contests like this at work back in the 80's to see who could do it in the shortest (most obtuse) way. Its been years since I've done any of this but you could try something like this from the command line. :1,$s/^\(..... place 32 dots here\)....\(.*\)/\1####\2/ This should modify the entire file. There should be EXACTLY as many periods/dots between the first set of parens as you want to skip over. Then EXACTLY as many periods/dots between the first set of parens and second parens as you want to replace. Replace #### with the new numbers/text you want. (doesnt have to be the same length as what is being replaced) This works by matching the begining characters and puting them in a substring then matching the replacement characters and finally puting the tail end of the string in another stubstring. Then it puts the first substring back, then the new text, followed by the second substring. Hopefully, I remembered correctly and the WEB tools didn't mangle any of the special characters. (NOTE: I did download a vi versions for windows and this does work.) Regular expressions are cool! and very consistent across unix. For all of you wondering how come I got so deep into such techno dweeb stuff, its because back in the "old days" when you were on a 300 baud modem, you wanted as little screen activity as possible and the ":" commands of vi are exactly the same as the "ed" commands which is where vi came from. --- bill |
Lo-Fi Version | Time is now: 22nd May 2024 - 09:30 PM |
All rights reserved 914World.com © since 2002 |
914World.com is the fastest growing online 914 community! We have it all, classifieds, events, forums, vendors, parts, autocross, racing, technical articles, events calendar, newsletter, restoration, gallery, archives, history and more for your Porsche 914 ... |