Skip to content
Advertisement

I want to extract any text between two symbol

I need to execute the file (a.out) and at the same time, I just need specific parts of the output, not everything. which is either located between these two string [[….]] or ((…..)). and I don’t have any idea where the other text is located (there is no specific pattern) and how the output looks like?

for example: if I run the file

JavaScript

I will get this in the console,

JavaScript

Instead, I want a text file that will look like:

JavaScript

I tried the grep/sed/tr but each time I got something different. I also want to use them at the same time with executing the program

e.g.

JavaScript

Update: I tried different commands and they all gave me the same result without changing my output.

JavaScript

It seems like because there are many [[ and ]], So it confused or it wasn’t working on all the line of output

Advertisement

Answer

You may use this sed:

JavaScript

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement