PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: "Dr dot J dot S dot Farhat" <jfarhat at janainc dot com>
Subject: Re: Control Characters in a Pattern
Date: Feb 25 1996 2:08AM


At 02:56 PM 2/22/96 -0500, T. Kim Nguyen wrote:
>If you are on SunOS, you could use "dos2unix".
>
>NAME
>     dos2unix - convert text file from DOS format to ISO format
>
>SYNOPSIS
>     dos2unix [ -ascii ] [ -iso ] [ -7 ] originalfile  converted-
>     file
>
>DESCRIPTION
>     dos2unix converts characters in the DOS  extended  character
>     set to the corresponding ISO standard characters.
>
>     This command can be invoked from either DOS or SunOS.   How-
>     ever,  the  filenames must conform to the conventions of the
>     environment in which the command is invoked.
>
>
>    >> How can I remove control characters in a string?
>    >> 
>    >> I created a data file on my PC and ftpd the file to the UNIX system so
>    >> that I can BCP into Sybase. When I use vi, the last character showns
up as ^M.
>    >> I want to delete this. It is a redundant character. I am writing a
script
>    >> to delete such control characters, not only at the end of the line
but anywhere
>    >> in the file. I know chop function only deletes at the end of the
line but what
>    >> about finding the control characters set in the middle of the line?
>    >> 
>    >> Thank you in advance.
>    >> 
>    >> Subbarao.
>    >> chitturi@dns1.state.mi.us
>    >> 

Here is a simple script from converting PC text to Unix

for afilename
do
    tr '\015'  ' ' < "$afilename" > "tmp.$afilename"
    mv "tmp.$afilename" "$afilename"
done

Basically you use the tr command to fined every carriage return and converts
it to space or nothing.

You can name this script as pc2unix and change the mode with chmod to
excutable. After
that you just pass one or group of files and it will take the carriage return.

Good Luck