LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-25-2008, 10:51 AM   #1
skydive814
LQ Newbie
 
Registered: Sep 2008
Posts: 3

Rep: Reputation: 0
extracting elements


I'm stuck between a rock and a hard place...hopefully you can help.

I have a text file filled with all sorts of junk....sprinkled throughout are "proprietary" markup tags. Here's an example:

Code:
COM blah 
COM blah
{{foo}}
  {{bar}}1{{/bar}} {{baz}}<MNFRAME_VAR_HERE>{{/baz}}
  {{blah}}<...>{{/blah}}     {{tag5}}off{{/tag5}}
COM junk I don't care about
COM junk I don't care about
{{foo}}
  {{bar}}2{{/bar}} {{baz}}<MNFRAME_VAR_HERE>{{/baz}}
  {{blah}}<...>{{/blah}}     {{tag5}}on{{/tag5}}
  • none of the "elements" have attributes....they are simply markup for variables coming from the mainframe
  • there can be multiple "elements" on a line
  • the white space between elements on the same line is unknown. you will see
    {{...}}{{....}} {{....}}
    on one line then see
    {{...}} {{....}} {{....}}
    on the next
  • there is no closeing {{foo}}. That's in a different file

what I need is a script that will extract all the {{???}} elements. My plan (at this point) is to pipe that through "sort -u" and create a DB table with a column for each unique element.

I'm still early in my research on the best way to accomplish my task, but in any case, a bash/sed/awk/perl script that would return my unique elements would be very helpful.

basically....a non-greedy 'grep -e "{{.*}}" filename'

any help is appreciated....

thanks,

-sky
 
Old 09-25-2008, 11:13 AM   #2
skydive814
LQ Newbie
 
Registered: Sep 2008
Posts: 3

Original Poster
Rep: Reputation: 0
maybe something like this:

Code:
grep "{{" DTAGSTHD | sed 's/[ \t]*{{/{{/g' | sed 's/}}{{/}}\n{{/g' | sed 's/[ \t]*$//'

Last edited by skydive814; 09-25-2008 at 11:16 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
trimming perl array elements homey Programming 7 02-17-2008 04:48 PM
Removing elements from startup ? Sabinou Mandriva 3 05-31-2006 03:21 AM
Photoshop Elements Thorlord Linux - Software 6 05-17-2006 04:21 AM
xml elements in css trscookie Programming 3 01-16-2006 11:07 AM
Why are some elements missing after using strcat() monil Programming 4 03-08-2005 08:40 AM


All times are GMT -5. The time now is 09:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration