<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Adding and removing control characters from a document in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/adding-and-removing-control-characters-from-a-document/m-p/5186533#M679976</link>
    <description>and in awk:&lt;BR /&gt;&lt;BR /&gt;$  cat awk.scr&lt;BR /&gt;==============================&lt;BR /&gt;&lt;BR /&gt;BEGIN {&lt;BR /&gt;ff="\014"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;if (NR == 1)&lt;BR /&gt;{&lt;BR /&gt;   sub(ff,"");&lt;BR /&gt;}&lt;BR /&gt;print $0;&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;END{&lt;BR /&gt;print ff;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;=======================================&lt;BR /&gt;&lt;BR /&gt;awk -f awk.scr &lt;YOURFILE&gt; &amp;gt; &lt;YOUR_MODIFIED_FILE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/YOUR_MODIFIED_FILE&gt;&lt;/YOURFILE&gt;</description>
    <pubDate>Thu, 09 Jul 2009 17:33:43 GMT</pubDate>
    <dc:creator>OldSchool</dc:creator>
    <dc:date>2009-07-09T17:33:43Z</dc:date>
    <item>
      <title>Adding and removing control characters from a document</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/adding-and-removing-control-characters-from-a-document/m-p/5186531#M679974</link>
      <description>My first 'real' script is working nicely now, but I would really like to improve it. I need to remove a single form feed character (^L) from a file and add a single form feed character to the end. I found several ways to add or remove control characters throughout the document but the only way I found to just add or remove a single character just at the beginning or end involves an external file, FEEDFILE, which contains a single form feed character.&lt;BR /&gt;&lt;BR /&gt;What works currently:&lt;BR /&gt;&lt;BR /&gt;if [[ $(head -c -n 1 ${OUTPUTFILE}) = $(head -c -n 1 ${FEEDFILE}) ]]&lt;BR /&gt;then&lt;BR /&gt;  #remove form feed character from the beginning&lt;BR /&gt;  mv ${OUTPUTFILE} ${TEMPFILE}&lt;BR /&gt;  tail -c +2 ${TEMPFILE} &amp;gt; ${OUTPUTFILE}&lt;BR /&gt;  rm ${TEMPFILE}&lt;BR /&gt;fi&lt;BR /&gt;if [[ $(tail -n 1 ${NEWOUT}) != $(head -c -n 1 ${FEEDFILE}) ]]    &lt;BR /&gt;then&lt;BR /&gt;  #add a form feed character to the end&lt;BR /&gt;  mv ${NEWOUT} ${TEMPFILE}&lt;BR /&gt;  cat ${TEMPFILE} ${FEEDFILE} &amp;gt; ${NEWOUT}&lt;BR /&gt;  rm ${TEMPFILE}&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;These methods remove all the ^M's, not just one:&lt;BR /&gt;&lt;BR /&gt;sed 's/^L/^g' ${OUTPUTFILE} &amp;gt; ${TEMPFILE}&lt;BR /&gt;&lt;BR /&gt;tr -d "\14" &amp;lt; ${INPUTFILE} &amp;gt; ${TEMPFILE}&lt;BR /&gt;&lt;BR /&gt;perl -p -i -e 's/^L//g' ${INPUTFILE}&lt;BR /&gt;&lt;BR /&gt;With awk I can remove the first form feed but I don't want to do that unless it's the first character of the file:&lt;BR /&gt;&lt;BR /&gt;awk '/\014/&amp;amp;&amp;amp;f&amp;lt;1{sub("\014","");1' ${OUTPUTFILE} &amp;gt; ${TEMPFILE}&lt;BR /&gt;&lt;BR /&gt;Ideas appreciated!!!</description>
      <pubDate>Thu, 09 Jul 2009 16:21:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/adding-and-removing-control-characters-from-a-document/m-p/5186531#M679974</guid>
      <dc:creator>Amy Pondolfino</dc:creator>
      <dc:date>2009-07-09T16:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: Adding and removing control characters from a document</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/adding-and-removing-control-characters-from-a-document/m-p/5186532#M679975</link>
      <description>Hi Amy:&lt;BR /&gt;&lt;BR /&gt;If I understand your requirement, try this:&lt;BR /&gt;&lt;BR /&gt;# perl -0777 -pi.old -e 's/^\014//;s/$/\014/' file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 09 Jul 2009 16:40:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/adding-and-removing-control-characters-from-a-document/m-p/5186532#M679975</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-07-09T16:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: Adding and removing control characters from a document</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/adding-and-removing-control-characters-from-a-document/m-p/5186533#M679976</link>
      <description>and in awk:&lt;BR /&gt;&lt;BR /&gt;$  cat awk.scr&lt;BR /&gt;==============================&lt;BR /&gt;&lt;BR /&gt;BEGIN {&lt;BR /&gt;ff="\014"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;if (NR == 1)&lt;BR /&gt;{&lt;BR /&gt;   sub(ff,"");&lt;BR /&gt;}&lt;BR /&gt;print $0;&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;END{&lt;BR /&gt;print ff;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;=======================================&lt;BR /&gt;&lt;BR /&gt;awk -f awk.scr &lt;YOURFILE&gt; &amp;gt; &lt;YOUR_MODIFIED_FILE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/YOUR_MODIFIED_FILE&gt;&lt;/YOURFILE&gt;</description>
      <pubDate>Thu, 09 Jul 2009 17:33:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/adding-and-removing-control-characters-from-a-document/m-p/5186533#M679976</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-07-09T17:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Adding and removing control characters from a document</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/adding-and-removing-control-characters-from-a-document/m-p/5186534#M679977</link>
      <description>with sed:&lt;BR /&gt;&lt;BR /&gt;as a "one-liner"&lt;BR /&gt;&lt;BR /&gt;sed "1s/^L//1 ; $a^L" yourfile &amp;gt; your_mod_file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;$ cat sed.scr&lt;BR /&gt;=================&lt;BR /&gt;1s/^L//1&lt;BR /&gt;$a^L&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;sed -f sed.scr &lt;YOURFILE&gt; &amp;gt; your_mod_file&lt;BR /&gt;&lt;BR /&gt;gnu variants also support -i (in-place) option as I recall&lt;/YOURFILE&gt;</description>
      <pubDate>Thu, 09 Jul 2009 18:16:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/adding-and-removing-control-characters-from-a-document/m-p/5186534#M679977</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-07-09T18:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: Adding and removing control characters from a document</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/adding-and-removing-control-characters-from-a-document/m-p/5186535#M679978</link>
      <description>one wonders if any of the above proved useful?</description>
      <pubDate>Wed, 15 Jul 2009 13:39:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/adding-and-removing-control-characters-from-a-document/m-p/5186535#M679978</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-07-15T13:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: Adding and removing control characters from a document</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/adding-and-removing-control-characters-from-a-document/m-p/5186536#M679979</link>
      <description>Indeed, very useful! Thanks to everyone who replied! I love having all these options, and I'm still playing around with them a bit (there were some other deadlines that came up). I especially like the perl code, and I'm planning to learn more about perl in general.</description>
      <pubDate>Wed, 15 Jul 2009 13:51:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/adding-and-removing-control-characters-from-a-document/m-p/5186536#M679979</guid>
      <dc:creator>Amy Pondolfino</dc:creator>
      <dc:date>2009-07-15T13:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: Adding and removing control characters from a document</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/adding-and-removing-control-characters-from-a-document/m-p/5186537#M679980</link>
      <description>Thanks again for the invaluable help with my script!</description>
      <pubDate>Wed, 15 Jul 2009 13:53:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/adding-and-removing-control-characters-from-a-document/m-p/5186537#M679980</guid>
      <dc:creator>Amy Pondolfino</dc:creator>
      <dc:date>2009-07-15T13:53:52Z</dc:date>
    </item>
  </channel>
</rss>

