Operating System - HP-UX
1830902 Members
1827 Online
110017 Solutions
New Discussion

ux2dos create a sign(^Z) at the end of the text file

 
Harvey Xu
New Member

ux2dos create a sign(^Z) at the end of the text file

when i try to convert a text file form unix to dos format ,but i found a problem ,a sign has been created at the end of the created dos file. just like "^Z" , is anyone know how to remove or prevent this issue ?

command :ux2dos unixfile.cfg > dosfile.cfg
10 REPLIES 10
Aneesh Mohan
Honored Contributor

Re: ux2dos create a sign(^Z) at the end of the text file

Hi,

OPen the file in VI and do replace :%s/^Z//g


esc :%s/Type CntrlV Z//g


Aneesh
Harvey Xu
New Member

Re: ux2dos create a sign(^Z) at the end of the text file

hi ,
thank you so much ,but i want to know whether have another way to prevent this sign when i execute the command ,Coz i have a lot of files need to convert ,so i can not use vi edit it one bye one .i make a perl script to do this . any other idea ?

thanks
Harvey
Laurent Menase
Honored Contributor

Re: ux2dos create a sign(^Z) at the end of the text file

tr -d "\032"


ux2dos myfile|tr -d "\032" >resultfile
Harvey Xu
New Member

Re: ux2dos create a sign(^Z) at the end of the text file

great !!!
thanks all of you ...
but i am a tiro ,no points assign to you now. i won't forgot it when i earned .
Bill Hassell
Honored Contributor

Re: ux2dos create a sign(^Z) at the end of the text file

Why do you want to remove ctlr-Z? It is the standard DOS/Windows end-of-file marker. The only reason you see it is that you are likely using vi to look at the converted file. Windows and DOS prefer the ctrl-Z as an EOF marker:

http://en.wikipedia.org/wiki/Control-Z


Bill Hassell, sysadmin
James R. Ferguson
Acclaimed Contributor

Re: ux2dos create a sign(^Z) at the end of the text file

Hi Harvey:

Instead if using 'ux2dos' and dealing with the ^Z you could do:

# perl -pe 's{\n}{\r\n}' file

If you wish to perform an in-place update, do:

# perl -pi.old -e 's{\n}{\r\n}' file

This will create a backup of the original file as 'file.old' and perform the substitution you want.

Regards!

...JRF...
Steven Schweda
Honored Contributor

Re: ux2dos create a sign(^Z) at the end of the text file

> Instead if using 'ux2dos' [...]

Or, ...

Couldn't "sed" handle this job?

I've seen people use Zip ("-l") and UnZip to
do this. (Probably not optimal, but if the
programs are handy ...)
James R. Ferguson
Acclaimed Contributor

Re: ux2dos create a sign(^Z) at the end of the text file

Hi (again):

> Steven: Couldn't "sed" handle this job?

Of course it could. I never said that Perl was the only option, only that it "could". TMTOWTDI.

If you prefer 'sed' the GNU version offers in-place replacement akin to Perl's '-i' switch. With the standard HP-UX 'sed' you must work through your own temporary file.

Regards!

...JRF...
Harvey Xu
New Member

Re: ux2dos create a sign(^Z) at the end of the text file

thanks ...
James R. Ferguson
Acclaimed Contributor

Re: ux2dos create a sign(^Z) at the end of the text file

Hi Harvey:

Your "thanks" is certainly appreciated. However, please read this about assigning points:

http://forums11.itrc.hp.com/service/forums/helptips.do?#28

Regards!

...JRF...