|
|

|
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. |
|
|
| Rusty |
Aug 9 2004, 09:18 AM
Post
#1
|
|
914 Guru ![]() ![]() ![]() ![]() ![]() Group: Retired Admin Posts: 7,992 Joined: 24-December 02 From: North Alabama Member No.: 6 Region Association: South East States
|
Sorry for the OT post.
I have a text file that I need to edit. I need to edit every record on that file (record positions 34-37) to change whatever is in those positions (only) to a four digit number. What is currently in those positions varies dramatically. My only text editor I have on the system is vi. Anyone got a command I can use? thanks, Lawrence |
![]() ![]() |
| Gint |
Aug 9 2004, 05:15 PM
Post
#2
|
|
Mike Ginter ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Admin Posts: 16,105 Joined: 26-December 02 From: Denver CO. Member No.: 20 Region Association: Rocky Mountains |
Get this figured out yet? Here's a very simple solution and explanation. This assumes that each line only contains one "BA0...." string. Otherwise we'll have to use some of the positional commands some of these other "hacks" (and I mean that in the nicest way possible (IMG:style_emoticons/default/rolleyes.gif) ) listed. Also, all of this changes if the old replacement string has a data value that needs to relate to the replacement string. If the replacement string for every line will be the same, then it's this simple. If not, we have to be more creative.
cat tmpfile | sed 's/BA0..../BAO1234/g' > tmpfile_new cat your file (tmpfile in this example), pipe it to sed. the "s" means substitute. Your sub-ing BA.... (that's four dots, or wildcards for one character each in regular expression speak) for the char set infollowing the next forward slash. In this case you would want to replace them with the sam BA0 and then the 4 character string you want to use as a replacement string. I used 1234 in this example. The > re-directs the new text to a new file, leaving the existing file intact. You can then rename the new file as necessary. If you just run this cat tmpfile | sed 's/BA0..../BAO1234/g' without the file re-direct, you can see the output on your terminal display and verify it's what you want before creating the new file. This should work on any Solaris system (I tested it on one to make certain). The systems standard path should have the location of sed and cat. |
Lawrence OT: Calling unix experts Aug 9 2004, 09:18 AM
fiid hey,
It sounds like you need to make this edit on... Aug 9 2004, 09:46 AM
thomasotten upload the text into a database like mysql, if you... Aug 9 2004, 10:04 AM
sgomes Wow! Two things:
1) vi is still getting disc... Aug 9 2004, 10:05 AM
mikester If the records were all the same it would be easy ... Aug 9 2004, 10:07 AM
vortrex are you using real vi, as in on a unix station of ... Aug 9 2004, 10:09 AM
Lawrence Here's a sample record:
000104659 W91XLM4094... Aug 9 2004, 10:17 AM
Root_Werks :idea: Oh man, it has been a while. But even So... Aug 9 2004, 10:39 AM
Lawrence The BA0 only varies a bit. I could run several sw... Aug 9 2004, 10:48 AM
thomasotten Ok, how about writting a shell script that reads e... Aug 9 2004, 10:54 AM
kafermeister Ok, Don't laugh. The last time I ran into som... Aug 9 2004, 11:00 AM
Lawrence Thomas,
The rest of the data is different in ever... Aug 9 2004, 11:01 AM
thomasotten yeah, it is just looking for the same position. I... Aug 9 2004, 11:04 AM
mikester The simplest way to do this is in vi.
If it's... Aug 9 2004, 11:18 AM
tat2dphreak ok, if this is on a windows machine that you are t... Aug 9 2004, 11:56 AM
fiid
fiid We should start a 914 Wiki is what we should do. Aug 9 2004, 04:24 PM
Lawrence Thanks guys! It's morning here now... I... Aug 9 2004, 09:44 PM
Gint Here's an even shorter version:
sed -e 's... Aug 9 2004, 10:05 PM
Root_Werks Me thinks Gint wins the prize for this one! ... Aug 10 2004, 11:53 AM
bperry Man its been a while but I love vi and regular exp... Aug 10 2004, 12:35 PM![]() ![]() |
|
Lo-Fi Version | Time is now: 25th December 2025 - 04:18 AM |
| 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 ... |