Skip to content
Advertisement

Linux read file line by line, print regex and print everything between two patterns

I made this script:

JavaScript

Output of hc_connesse is:

JavaScript

I’m not able to print SE401 from hc_connesse.

The query is made on 45 different server and without putting the SE04 before the table will be impossible to understand which data are from where.

Tried another For cycle inserting another awk before the other.

Tried putting the two awk on one line.

Most probably i wrote something wrong because any change i make to the script, console is like awaiting input.

Do you have any idea on how to print the SE04?

Advertisement

Answer

It is very hard to guess the relationship between the body of your question and its title. If I understand you correctly, you want to print the first line (SE followed by digits) AND the output of the database query.

Try:

JavaScript

What awk does here is to print every line starting with SE, + or |. If you want something else, please edit your question to make it understandable.

It is probable that you don’t want to keep a copy of hc_connesse. In that case, just take away the string tee hc_connesse | from the command above.

Output:

JavaScript
Advertisement