^M

Hi friends:
    I find there alway a word '^M' in my file when i ftp it to HP,I am tired about the word '^M'.How to delete '^M' from my file?
mingweiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
tr -d '\015'
or ftp in ascii mode
0
ahoffmannCommented:
dos2ux file > newfile  # on HP

ozo, ftp in ascii mode ??
assumes that the ftp client is one of the crazy (or stupid) ones which makes changes while putting files (like M$'s)
I highly recommend not trusting such things, you may be surprised by the results, sometimes ;-)
0
mingweiAuthor Commented:
Thanks for your comment,but I think there must be some way to delete ^M in vi editor,can you help me again?
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

ahoffmannCommented:
:%s/^V^M//g

# where  ^V  means ctrl-V and ^M means return key, you will not see the ^V while input
#
# or if you have vim or similar
:set notextmode
:w
0
mingweiAuthor Commented:
Hi ahoffmann:
first way you tell report:
Substitute pattern match failed
second way you tell report:
not such option
0
ahoffmannCommented:
> Substitute pattern match failed
then you did not type it correctly

BTW, a slightly better solution
:%s/^V^M$//g
0
mingweiAuthor Commented:
Sorry :%s/^V^M//g
No using!
Problem just like before!
0
ozoCommented:
How do you know the file contains ^M?
0
ahoffmannCommented:
ozo, it is visible verbatim in standard vi (but not vim or alike); HP-UX uses standard vi, usually

nota bene: with "standard vi" I mean the original Berkley distribution, which is used in (all)most proprietary UNIX versions (AIX, HP-UX, IRIX, SunOS, ULTRIX, ...)
while FreeBSD, NetBSD and Linux are more likely using vim (or friends) as their default vi
0
bedotCommented:
replacing or deleting a string in a file can be done under vi, or sed:
IE, my file tst containing hello^M^J:

(^M is a return represented here with metacharacter \r)
# od -bc tst
0000000   h   e   l   l   o  \r  \n  \0
        150 145 154 154 157 015 012 000
0000007

^M is obtained typing ^Vreturn: ^V is an introducer of control character;  so, i can replace ^M with x
# cat tst | sed -e s/^M/x/ | od -bc
0000000   h   e   l   l   o   x  \n  \0
        150 145 154 154 157 170 012 000
0000007



if i want suppress the ^M, nothing in the second part of the explession


# cat tst | sed -e s/^M// | od -bc
0000000   h   e   l   l   o  \n
        150 145 154 154 157 012
0000006



under vi, if you want suppress all the ^M in each line, you must
typein the command line (acceded with escape : )
1,$ s/^V^M//

that will write in the command line  (^V being an introducer of control code)
1,$ s/^M//

1,$ representing from the 1st line to the last

1,100 to do from the 1st to the 100th



hope fully helpfull for you
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mingweiAuthor Commented:
Thanks for your answer!That is what i wanted!
0
dankhCommented:
hi,

  an even easier way:

%s/^M//g
0
ahoffmannCommented:
dankh, small and simple not accepted :(
0
bedotCommented:
AHOFF, don't be so weary!
if you give a so short response at an expert, is able to understand;
it seem that minqwei is not a specialist unix: so it need a response that help him to understand: need more explanation;

You yave loss only 1 point

0
ahoffmannCommented:
je faît des blaque, tous les jours ... :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.