Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to remove multiple ^M from an ftp text file 2

Status
Not open for further replies.

jpor

Technical User
Nov 29, 2000
212
GB
Hi guys,

Seem to recall that there was a thread on here for a script or a way to remove multiple ^M from each line of a text file that I have transferred to a Unix box.

Can someone please point me in the right direction.

Thanks in advance.


 
Depends to some extent on flavour, but dos2unix does the trick for Solaris.
 
It's on AIX 4.3.3

I know there is a scrit or command of some type that goes through a file and removes the ^M from the end of each line.

The poroblem is to do this manually will mean an hour.

If someone can point me in the right direction where this thread is or how I can achieve this.
 
^M is ascii 15 so :
sed 's/'`echo "\015"`'//g' file > filenew

should do it !

Dickie Bird (:)-)))
 
You can try something like this:
Code:
cr=`echo "\r"`
sed -e &quot;s!$cr\$!!&quot; <dosfile >unixfile
You can also consider to transfer files in ascii mode with ftp.
 
Thanks guys. Have used Dickiebirds example. But I will consider that PHV. And also a decent FTP program to boot as well.
;-)

 
You can also use tr:
Code:
tr -d &quot;\015\032&quot; < dosfile > unixfile
015 is CR
032 is Ctrl-Z
 
AIX = IBM's Flavour of UNIX

DOSREAD = A DOS reading tool in AIX.

Although this did come from an e-mail. The file originated from a UNIX system.
So DOSREAD is not neccessary.


( &quot;To become Wise, first you must ask Questions&quot;)
 
I am not a 100% sure, but I seem to recall that
&quot;set ff=unix&quot; then a wq!
in vi does the same trick.
 
dosread <dosfilename> <unixfilename>

should do it, but you have to have bos.dosutils installed. Not all systems do. Besides Dickibird's, PHV's and theotyflos' methods, you can open the file with vi and type:

:
%
s
/
Ctrl
v
Ctrl
M
/
/
g

to eliminate the ^M. I couldn't get BIS' method to work, but it could be the version of vi I have.

 
Thanks all. Got a few to use in the future.


( &quot;To become Wise, first you must ask Questions&quot;)
 
Simplest and quickest solution is to just re-transfer it to AIX using ASCII mode instead of binary mode. If you don't have the source on your PC anymore, just transfer it back to the PC in binary mode, then transfer again to AIX in ASCII.

At Bull's freeware site you will find an AIX package for dos2unix, ask your AIX sysadmin to install that for future use.

IBM Certified Confused - MQSeries
IBM Certified Flabbergasted - AIX 5 pSeries System Administration
MS Certified Windblows Rebooter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top