Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'll assume the first few characters are also part of the output, but the solution does not depend on it.</p> <p>To remove extra spaces, you can use <code>tr -s</code>, which will remove repeats of the passed characters. Compare the unchanged with the tr-ed output (third and fourth lines in both cases):</p> <pre><code>lynx@mobilis gemrb 0 $ echo "--&gt; '044' 0 '' 0 &gt; 1&gt; '' 0 0" --&gt; '044' 0 '' 0 1&gt; '' 0 0 lynx@mobilis gemrb 0 $ echo "--&gt; '044' 0 '' 0 1&gt; '' 0 0" | tr -s ' ' --&gt; '044' 0 '' 0 1&gt; '' 0 0 </code></pre> <p>So the only thing that remains is removing that newline. You could do that with <code>tr</code> too (<code>-d</code> for delete), but then you would also remove the newline that would separate the string from the next register.</p> <p>I don't know how stable these register dumps are, so here is a solution that does not involve regular expressions — it just prints the line with the newline included only for every second line:</p> <pre><code>i=1 echo "--&gt; '044' 0 '' 0 1&gt; '' 0 0" | tr -s ' ' | while read line; do if [[ $i == 1 ]]; then echo -n "$line"; let i+=1; else echo " $line"; let i-=1; fi; done --&gt; '044' 0 '' 0 1&gt; '' 0 0 </code></pre> <p>To use it, just replace the <code>echo 'long register dump'</code> string with your register dumper program.</p> <p>EDIT: Ok, if that is your whole command chain, then you have to group them or parts of their output will not be caught by the filter. But I guess <code>cdmao</code> is just for some initialisation (if it isn't, add everything in another subshell or curly brackets)? </p> <p>The main problem is that you didn't complete the while loop (a <code>done</code> missing somewhere). Not sure if I placed it correctly, but try this:</p> <pre><code>cdmao; (echo "SELECT nulog FROM POSTE WHERE numan='5512204';"|cuser|grep "\--"|grep -v nulog|cut - c5-11;) | while read poste_id; do echo "SELECT key_id,genrtou,chiftp, sonsurson, mnemo, order_mla, key_mla FROM KEYBOARD WHERE poste_id='$poste_id';"; done |cuser| tr -s ' ' | while read line; do if [[ $i == 1 ]]; then echo -n "$line"; let i+=1; else echo " $line"; let i-=1; fi; done </code></pre> <p>It can be done in a prettier way, but I don't know some of the commands involved, so I kept it close to your version. Anyway, use some formatting and syntax errors will be much easier to spot.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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