Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am not familiar at all with a program called gaussian, so I have no clue what the original input looked like. If someone posts an example I might be able to give an even shorter solution.</p> <p>However, as far as I got it the OP is contented with the output of his/her code besided that he/she wants to append an increasing number to the lines inserted with <code>awk</code>.</p> <p>This can be achieved with the following line (adjusting the OP's code):</p> <pre class="lang-sh prettyprint-override"><code>grep -A 7 "Input orientation:" test.log | grep -A 5 "C" | awk '/C/{print "structure number"++i}1' | sed '/--/d' &gt; test.out </code></pre> <p><strong>Addendum:</strong></p> <p>Even without knowing the actual input, I am sure that one can at least get rid of the <code>sed</code> command leaving that piece of work to <code>awk</code>. Also, there is no need to quote a single character grep pattern:</p> <pre class="lang-sh prettyprint-override"><code>grep -A 7 "Input orientation:" test.log | grep -A 5 C | awk '/C/{print "structure number"++i}!/--/' &gt; test.out </code></pre> <p>I am not sure since I cannot test, but it should be possible to let <code>awk</code> do the <code>grep</code>'s work, too. As a first guess I would try the following:</p> <pre class="lang-sh prettyprint-override"><code>awk '/Input orientation:/{li=7}!li{next}{--li}/C/{print "structure number"++i;lc=5}!lc{next}{--lc}!/--/' test.log &gt; test.out </code></pre> <p>While this might be a little bit longer in code it is an <code>awk</code>-only solution doing all the work in one process. If I had input to test with, I might come up with a shorter solution.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload