<?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: need to remove carriage return from end of last record in a file in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669635#M50573</link>
    <description>And just to add to the mix:&lt;BR /&gt;&lt;BR /&gt;tr -d \\015 &amp;lt; filename &amp;gt; newfilename&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;dos2ux filename &amp;gt; newfilename&lt;BR /&gt;</description>
    <pubDate>Fri, 22 Feb 2002 15:42:50 GMT</pubDate>
    <dc:creator>Kirk Gardner</dc:creator>
    <dc:date>2002-02-22T15:42:50Z</dc:date>
    <item>
      <title>need to remove carriage return from end of last record in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669627#M50565</link>
      <description>Howdy,&lt;BR /&gt;&lt;BR /&gt;I get files with "non-printable carriage return characters" (\n in Textpad) at the end of each row. On the last row this causes an "extra row" when looked at by non-UNIX text editors. This last carriage return needs to be stripped somehow. Any ideas?&lt;BR /&gt;&lt;BR /&gt;In vi I don't see anything except my normal rows. I saw that some folks see ^M, but I don't. How do I see the non printable characters in vi?</description>
      <pubDate>Thu, 21 Feb 2002 21:16:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669627#M50565</guid>
      <dc:creator>Kevin Medlin</dc:creator>
      <dc:date>2002-02-21T21:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: need to remove carriage return from end of last record in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669628#M50566</link>
      <description>In vi, type the following:&lt;BR /&gt;&lt;BR /&gt;:1,$s/^V^M//&lt;BR /&gt;&lt;BR /&gt;The key sequence is CTRL+V and CTRL+M, only the "^M" will appear on screen.&lt;BR /&gt;This will remove th ^M character.&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Feb 2002 21:23:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669628#M50566</guid>
      <dc:creator>S.K. Chan</dc:creator>
      <dc:date>2002-02-21T21:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: need to remove carriage return from end of last record in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669629#M50567</link>
      <description>Hi Kevin,&lt;BR /&gt;&lt;BR /&gt;There are many ways to get rid of ^M from a file here a few:&lt;BR /&gt;&lt;BR /&gt;in VI&lt;BR /&gt;:%s/^V^M//g&lt;BR /&gt;&lt;BR /&gt;^V is control V and ^M is control M or Enter&lt;BR /&gt;&lt;BR /&gt;USING SED:&lt;BR /&gt;sed 's/^V^M//g' foo &amp;gt; foo.new&lt;BR /&gt;&lt;BR /&gt;Also:&lt;BR /&gt;strings foo &amp;gt; foo.new&lt;BR /&gt;should work&lt;BR /&gt;&lt;BR /&gt;-Shabu</description>
      <pubDate>Thu, 21 Feb 2002 21:23:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669629#M50567</guid>
      <dc:creator>SHABU KHAN</dc:creator>
      <dc:date>2002-02-21T21:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: need to remove carriage return from end of last record in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669630#M50568</link>
      <description>I suspect what is happening is that you are sharing text files between UNIX and Windows. The Windows guys expect each line to end with a CR/LF pair while the UNIX guys expect only a LF. There are a couple of utilities that will do the conversion for you. dos2ux and ux2dos. Man ux2dos and dos2ux for details.&lt;BR /&gt;&lt;BR /&gt;A good way to see all the characters in the file is via the od command. od -c myfile will display the stuff in a readable form.&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Feb 2002 21:27:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669630#M50568</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-02-21T21:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: need to remove carriage return from end of last record in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669631#M50569</link>
      <description>:set list &lt;BR /&gt;can be used to display non-printing characters in vi.</description>
      <pubDate>Thu, 21 Feb 2002 22:16:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669631#M50569</guid>
      <dc:creator>Alan Riggs</dc:creator>
      <dc:date>2002-02-21T22:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: need to remove carriage return from end of last record in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669632#M50570</link>
      <description>Hi,&lt;BR /&gt;Have these files been ftp'd to a Unix filesystem fro a DOS/Windows system? If so, it's likely that the ftp was done in binary mode.&lt;BR /&gt;While you can remove those pesky ^M characters using sed or dos2ux, I find that these CRs do not appear at all if the file is ftp'd in ascii mode.&lt;BR /&gt;</description>
      <pubDate>Fri, 22 Feb 2002 05:51:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669632#M50570</guid>
      <dc:creator>Deepak Extross</dc:creator>
      <dc:date>2002-02-22T05:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: need to remove carriage return from end of last record in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669633#M50571</link>
      <description>Thanks for the great responses.&lt;BR /&gt;&lt;BR /&gt;I am creating the file on UNIX and then ftp'ing to a Windows server. The problem is when they try to load the file in SQL server it blows there script on that last non-printable character. It tries to load an empty row.&lt;BR /&gt;&lt;BR /&gt;I did ':set list' command and I can see a $ (dollar sign) at the end of each row. There are no ^Ms or ^Vs in the file.&lt;BR /&gt;&lt;BR /&gt;I did 'ux2dos myfile &amp;gt; newfile'. This put ^Ms in newfile. It also added a new row to the end of newfile that has '^Z$' only.&lt;BR /&gt;&lt;BR /&gt;I don't want to remove the non-printable character from every row. I just want it removed from the last row. Also, I would like to be able to add the command string to my ftp script so this would not be a manual process.</description>
      <pubDate>Fri, 22 Feb 2002 14:46:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669633#M50571</guid>
      <dc:creator>Kevin Medlin</dc:creator>
      <dc:date>2002-02-22T14:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: need to remove carriage return from end of last record in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669634#M50572</link>
      <description>Hi Kevin,&lt;BR /&gt;&lt;BR /&gt;When you ftp the file from UNIX to Windows (or vice versa), you need to use ASCII mode.  This will take care of the "line delimiting" difference between UNIX and Windows.&lt;BR /&gt;&lt;BR /&gt;As info, UNIX uses a newline (actually the same ascii code as a linefeed) character to delimit lines where Windows uses a linefeed and a carriage return.&lt;BR /&gt;&lt;BR /&gt;If I read your post correctly, you have a blank line at the end of the file when you create it in UNIX.  You need to delete that blank line before loading the file into SQL Server.  Maybe you can modify how the file is created to not append the last blank line.&lt;BR /&gt;&lt;BR /&gt;To better see what the last line is, use od.  If the last line is blank, you would see:&lt;BR /&gt;tail -1 file | od -cb&lt;BR /&gt;0000000  \n&lt;BR /&gt;        012&lt;BR /&gt;0000001&lt;BR /&gt;&lt;BR /&gt;man ascii for more info on the ascii character set.&lt;BR /&gt;&lt;BR /&gt;Darrell</description>
      <pubDate>Fri, 22 Feb 2002 15:33:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669634#M50572</guid>
      <dc:creator>Darrell Allen</dc:creator>
      <dc:date>2002-02-22T15:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: need to remove carriage return from end of last record in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669635#M50573</link>
      <description>And just to add to the mix:&lt;BR /&gt;&lt;BR /&gt;tr -d \\015 &amp;lt; filename &amp;gt; newfilename&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;dos2ux filename &amp;gt; newfilename&lt;BR /&gt;</description>
      <pubDate>Fri, 22 Feb 2002 15:42:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669635#M50573</guid>
      <dc:creator>Kirk Gardner</dc:creator>
      <dc:date>2002-02-22T15:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: need to remove carriage return from end of last record in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669636#M50574</link>
      <description>Hi again Kevin,&lt;BR /&gt;&lt;BR /&gt;This is an ugly little script but it should work for you.  At least it did on my test file of ~500 lines.  The result is all lines print as is except the last which has the newline striped off.&lt;BR /&gt;&lt;BR /&gt;while read line&lt;BR /&gt;do&lt;BR /&gt;echo "$line\c"&lt;BR /&gt;while read line&lt;BR /&gt;do&lt;BR /&gt;echo "\n$line\c"&lt;BR /&gt;done&lt;BR /&gt;done &lt;INFILE&gt;outfile&lt;BR /&gt;&lt;BR /&gt;Darrell&lt;/INFILE&gt;</description>
      <pubDate>Fri, 22 Feb 2002 21:59:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-to-remove-carriage-return-from-end-of-last-record-in-a-file/m-p/2669636#M50574</guid>
      <dc:creator>Darrell Allen</dc:creator>
      <dc:date>2002-02-22T21:59:59Z</dc:date>
    </item>
  </channel>
</rss>

