Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6633789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:51:15+00:00 2026-05-25T22:51:15+00:00

I’m new to bash scripting and I’m having a hard time to figure out

  • 0

I’m new to bash scripting and I’m having a hard time to figure out this problem. I have about two hundred files that follow this pattern:

ANÁLISE DA GLOSA FUNGICIDA
A ANÁLISE RESULTA EM:
S='Glosa02626354' = "agente que destrói ou previne o crescimento de fungos"
    {antifúngico: O I]antifúngico clássico utilizado no tratamento não previne a disseminação típica da infecção.,
    agente antifúngico: Os resultados sugerem a utilização terapêutica do extrato do limão como I]agente antifúngico na Odontologia.,
    fungicida: A duração do ]fungicida no carpete tem garantia de cinco anos.,
    antimicótico: Os grupos nomearam o I]antimicótico e realizaram campanha de lançamento fictícia, com material técnico de divulgação e brindes.,
    agente antimicótico: Em caso de infecção, deverá ser instituído o uso de um I]agente antimicótico.}

Chave: FUNGICIDA <noun.artifact> 
ILI: 02626354
Sense 1
{02626354} <noun.artifact> antifungal, antifungal agent, fungicide, antimycotic, antimycotic agent -- (any agent that destroys or prevents the growth of fungi)
       => {13935705} <noun.substance> agent -- (a substance that exerts some force or effect)
           => {00005598} <noun.Tops> causal agent, cause, causal agency -- (any entity that causes events to happen)
               => {00001740} <noun.Tops> entity -- (that which is perceived or known or inferred to have its own distinct existence (living or nonliving))

In this case, I have to store the following values between braces: ‘antifúngico’, ‘agente antifúngico’, ‘fungicida’, ‘antimicótico’ and ‘agente antimicótico’ in one variable. Those words will of course be different in every file. For comparison, here’s another file:

ANÁLISE DA GLOSA VIA ÁPIA
A ANÁLISE RESULTA EM:
S='Glosa02634922' = "estrada da antiga Roma, na Itália, extendendo-se ao sul, de Roma a Brindisi; iniciada em 312 AC"
    {Via Ápia: Toda a I]Via Apia era conhecida quer pela sua extensão, quer pela sua extraordinária beleza.}

Chave: VIA ÁPIA <noun.artifact>
ILI: 02634922 
Sense 1
{02634922} <noun.artifact> Appian Way#1 -- (an ancient Roman road in Italy extending south from Rome to Brindisi; begun in 312 BC)
       => {03390668} <noun.artifact> highway#1, main road#1 -- (a major road for any form of motor transport)
           => {03941718} <noun.artifact> road#1, route#2 -- (an open way (generally public) for travel or transportation)
               => {04387207} <noun.artifact> way#6 -- (any artifact consisting of a road or path affording passage from one place to another; "he said he was looking for the way out")
                   => {00019244} <noun.Tops> artifact#1, artefact#1 -- (a man-made object taken as a whole)
                       => {00016236} <noun.Tops> object#1, physical object#1 -- (a tangible and visible entity; an entity that can cast a shadow; "it was full of rackets, balls and other objects")
                           => {00001740} <noun.Tops> entity#1 -- (that which is perceived or known or inferred to have its own distinct existence (living or nonliving))
                       => {00002645} <noun.Tops> whole#2, whole thing#1, unit#6 -- (an assemblage of parts that is regarded as a single entity; "how big is that part compared to the whole?"; "the team is a unit")
                           => {00016236} <noun.Tops> object#1, physical object#1 -- (a tangible and visible entity; an entity that can cast a shadow; "it was full of rackets, balls and other objects")
                               => {00001740} <noun.Tops> entity#1 -- (that which is perceived or known or inferred to have its own distinct existence (living or nonliving))

Here, the variable will have just one value, the string ‘Via Ápia’.


Update: I found a way to single out the lines that are relevant using some regular expression wizardry:

grep ':*\.,' file_name.txt

The output of this command for the first example is

    {antifúngico: O I]antifúngico clássico utilizado no tratamento não previne a disseminação típica da infecção.,
    agente antifúngico: Os resultados sugerem a utilização terapêutica do extrato do limão como I]agente antifúngico na Odontologia.,
    fungicida: A duração do ]fungicida no carpete tem garantia de cinco anos.,
    antimicótico: Os grupos nomearam o I]antimicótico e realizaram campanha de lançamento fictícia, com material técnico de divulgação e brindes.,
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:51:15+00:00Added an answer on May 25, 2026 at 10:51 pm

    If you just want to assign the result of your regex match to a variable in bash, then this should do it:

    myVar=$(cat file_name.txt|grep ':*\.,')
    

    EDIT:

    This may get you a bit closer:

    myVar=$(cat file_name.txt|grep ':*\.,'|./x.pl)
    

    Where x.pl is:

    #!/usr/bin/perl
    
    while (<STDIN>) {
        my @x = split /,/;
    
        foreach (@x) {
            print $1 . "\n" if /\{?\W*(.*?)\:/;
        }   
    }
    

    That will extract the 4 words you want, separated by newlines. I’m still not entirely clear if that’s what you want though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I've tracked down a weird MySQL problem to the two different ways I was
I know there's a lot of other questions out there that deal with this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.