title: What is the difference b/w two sed commands below?
body: <p>Information about the environment I am working in:</p>
  
  <pre><code>$ uname -a  
  AIX prd231 1 6 00C6B1F74C00  
  $ oslevel -s  
  6100-03-10-1119
  </code></pre>
  
  <hr>
  
  <p><strong>Code Block A</strong></p>
  
  <pre><code>( grep schdCycCleanup $DCCS_LOG_FILE | sed 's/[~]/ \
  /g' | grep 'Move(s) Exist for cycle' | sed 's/[^0-9]*//g' ) &gt; cycleA.txt
  </code></pre>
  
  <hr>
  
  <p><strong>Code Block B</strong></p>
  
  <pre><code>( grep schdCycCleanup $DCCS_LOG_FILE | sed 's/[~]/ \n/g' | grep 'Move(s) Exist for cycle' | sed 's/[^0-9]*//g' ) &gt; cycleB.txt
  </code></pre>
  
  <p>I have two code blocks(shown above) that make use of sed to trim the input down to 6 digits but one command is behaving differently than I expected.</p>
  
  <p><strong>Sample of input for the two code blocks</strong></p>
  
  <pre><code>Mar 25 14:06:16 prd231 ajbtux[33423660]: 20160325140616:~schd_cem_svr:1:0:SCHD-MSG-MOVEEXISTCYCLE:200705008:AUDIT:~schdCycCleanup - /apps/dccs/ajbtux/source/SCHD/schd_cycle_cleanup.c - line 341~ SCHD_CYCLE_CLEANUP - Move(s) Exist for cycle 389210~
  </code></pre>
  
  <p>I get the following output when the sample input above goes through the two code blocks.</p>
  
  <p><strong>cycleA.txt content</strong></p>
  
  <pre><code>389210
  </code></pre>
  
  <p><strong>cycleB.txt content</strong></p>
  
  <pre><code>25140616231334236602016032514061610200705008341389210
  </code></pre>
  
  <p>I understand that my last piped sed command (sed 's/[^0-9]*//g') is deleting all characters other than numbers so I omitted it from the block codes and placed the output in two additional files. I get the following output.</p>
  
  <p><strong>cycleA1.txt content</strong></p>
  
  <pre><code> SCHD_CYCLE_CLEANUP - Move(s) Exist for cycle 389210
  </code></pre>
  
  <p><strong>cycleB1.txt content</strong></p>
  
  <pre><code>Mar 25 15:27:58 prd231 ajbtux[33423660]: 20160325152758: nschd_cem_svr:1:0:SCHD-MSG-MOVEEXISTCYCLE:200705008:AUDIT: nschdCycCleanup - /apps/dccs/ajbtux/source/SCHD/schd_cycle_cleanup.c - line 341 n SCHD_CYCLE_CLEANUP - Move(s) Exist for cycle 389210 n
  </code></pre>
  
  <hr>
  
  <p>I can see that the first code block is removing every thing other that (SCHD_CYCLE_CLEANUP - Move(s) Exist for cycle 389210) and is using the tilde but the second code block is just replacing the tildes with the character n. I can also see that it is necessary in the first code block for a line break after this(sed 's/[~]/ ) and that is why I though having \n would simulate a line break but that is not the case. I think my different output results are because of the way regular expressions are being used. I have tried to look into regular expressions and searched about them on stackoverflow but did not obtain what I was looking for. Could someone explain how I can achieve the same result from code block B as code block A without having part of my code be on a second line?</p>
  
  <p>Thank you in advance</p>