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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove ctrl-m from beginning of records

Status
Not open for further replies.

prowe

Programmer
Dec 16, 2002
3
ZA
Hi

I have a file that originated from our IBM mainframe, with the first 2-bytes (I think!) of each record being a control-m character, which the mainframe guys can't remove.

When I vi the file it shows as ^?M

How do I remove this control character from the beginning of every record in the file?

Thanks
 
If you are using ftp, try the transfer in binary mode.
Else do a man on sed, with sed you will be able to remove the CRTL-M (carriage stuff) from the beginning of every line using a script. Too bad I.T. is not cash business

Luc Foata
Unix sysadmin, Oracle DBA
 
there are several methodes
what's that ^?M ??
in vi :%s/^V^M//g
on cmdline: cut -c2-
sed -e 's/^.//'
...
-----------
when they don't ask you anymore, where they are come from, and they don't tell you anymore, where they go ... you'r getting older !
 
Thanks guys.

Using dos2unix did not work.

Using 'cut -c1-2 file1' does not remove the first 2 chars from file1, although it 'works'.

Using vi (search for ^.M) or sed -e 's/^.M//' file1 >file2 work fine.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top