|
||||||
| Forums FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| Novell Archives Archived content from Novell openSUSE support forums |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi to all, newbe to the world of shell scripting, but I hope someone will
have an idea I can use. Have a large text file that contains one big memo field with several constants and a value, most of the time. Plan to convert this file to a MySQL as a table that will have several fields plus a large text memo remaining. For the most part this memo field has constants like P: for phone number, and Name: for the persons name, with there values following in the front part of this memo. Have been using the sed command with the constants that I know have values and are physically in correct positions. Example FixedRecord=`sed e s/[\ ]* P: / /` to change the phone number constant to a tab in front of the phone number value. After several e extensions of sed the FixedRecord is echo to a file for later processing. Now I need to figure out a way to do the same thing for constants that may or may not have values following them in the rest of the record. Anyone know of an easy way to check if a constant exist, and if it dose exist, dose it have a value. For example I want to check for the existence of Item Number: Desc: Start Date: End Date: Duration: Project: Supervisor: constants then check if they have values following them. So far I have done the following script RecordPart_1to19=`OrigRecord | cut d -f1-19` # first 19 tab fields of record RecordPart_20=`OrigRecord | cut d f20` # rest of record to search for new fields RecordPart_20 contains the following for tab conversion. Item Number: H14J649 Missing Desc: # this constant is missing and so is its value, TAB still required Start Date: 9/16/2004 End Date: Duration: 0017 Project: Supervisor: John Doe Results I want would be that the new record I build would contain $RecordPart_1to19 TAB H14J649 TAB TAB 9/16/2004 TAB TAB 0017 TAB TAB John Doe TAB $RecordPart_20 # RecordPart_20 when outputted should only contain what remains after the found constants and constant values are removed. Just need some ideas or be pointed to an example script that shows how to accomplish this task. Thanks in advance for any and all help. |
|
|||
|
Ljungers,
It appears that in the past few days you have not received a response to your posting. That concerns us, and has triggered this automated reply. Has your problem been resolved? If not, you might try one of the following options: - Do a search of our SDB at http://en.opensuse.org/SDB:SDB - Check all of the other information and support options available at http://www.opensuse.org/ - You could also try posting your message again. Make sure it is posted in the correct newsgroup. (http://support.novell.com/forums) Be sure to read the forum FAQ about what to expect in the way of responses: http://support.novell.com/forums/faq_general.html If this is a reply to a duplicate posting, please ignore and accept our apologies and rest assured we will issue a stern reprimand to our posting bot. Good luck! Your Novell Product Support Forums Team http://support.novell.com/forums/ |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|