Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Two join every pair of adjacent lines just pipe your output to <code>awk 'NR%2{line=$0;next}{print line sep $0}' sep=" &gt;&gt; "</code> adjusting <code>sep</code> to your need.</p> <p><strong>Addendum:</strong></p> <p>In response to the original author's comment I am going to explain some details of this solution:</p> <p><code>awk</code> processes input record-wise, without further options that is line-by-line. The (internal) variable <code>NR</code> stores the current record's number. <code>%</code> is the modulus operator, so <code>NR%2</code> evaluates to <code>1</code> for odd line numbers and <code>0</code> for even line numbers. <code>{...}</code> groups commands (so called 'action') to perform. Since <code>1</code> is considered "true" and <code>0</code> "false" the first action is only performed for odd line numbers. This action consists of two commands: First, the whole line (<code>$0</code>) is stored in the variable <code>line</code> and then the <code>next</code> record is processed (without considering any other action). For even lines, this action is not performed, so the second action is considered. Since there is no expression before the <code>{</code> the action is performed: the stored (i.e. previous) <code>line</code> is concatenated with a variable called <code>sep</code> and the current line (<code>$0</code>). The resulting string is printed (and automatically appended by <em>one</em> new-line in the end). The value of <code>sep</code> is handed to <code>awk</code> as a parameter to make it easy to adjust it without messing with the script. Since <code>awk</code> reads standard input and output without further arguments you can just pipe (<code>|</code>) the output of your find to <code>awk</code> (<code>find ... -exec ... -exec ... | awk ... &gt; ...</code>)</p>
 

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