1819681 Members
3721 Online
109605 Solutions
New Discussion юеВ

dos2unix command

 
SOLVED
Go to solution
Ahmed_41
Super Advisor

dos2unix command

Dear All,

i do have regular problems of files being opend on wordpad or notepad and then when i move them to HPUX they are damaged and i need to remove charcters from them like carriage return.

and i dont know how to resolve this, someone told me about do2unix, can someone tell me what does it do ? and where can i find this command on the HPUX machine ?
the thing is i think my .profile file was changed due to this and now i am unable to login using CDE since the file is changed or something like that. someone can help me plz ?


Thanks in advance
6 REPLIES 6
Ermin Borovac
Honored Contributor
Solution

Re: dos2unix command

On HP-UX command is called dos2ux and you can use it as follows (dos_file is file with DOS style line endings and unix_file is UNIX counterpart).

$ dos2ux dos_file > unix_file
Devender Khatana
Honored Contributor

Re: dos2unix command

Hi,

Moreover it is stored in /bin directory of your HP Box.

HTH,
Devender
Impossible itself mentions "I m possible"
Laurent Laperrousaz
Regular Advisor

Re: dos2unix command

Instead of using notepad or wordpad you should rather use Ultraedit which is a wonderful editor which can manage all text formats:
dos, unix, mac and propose you to save in any of these formats

It also has an explicit conversion function
Bharat Katkar
Honored Contributor

Re: dos2unix command

Hi,
When u copy i.e. ftp such file to Unix System first execute this command and then edit e.g. you have copied "file1" then:

# cat file | col -bx > file2

Now you can edit file2 which is readable.

Hope that helps.
Regards,
You need to know a lot to actually know how little you know
renarios
Trusted Contributor

Re: dos2unix command

Hi Ahmed,

Try:
cp .profile .profile.OLD
dos2ux .profile.OLD > profile

If that doesn't help, consider recovering your .profile from a backup?

Cheers,

Renarios

Nothing is more successfull as failure
Bill Hassell
Honored Contributor

Re: dos2unix command

Just to help clarify a bit--your files are not damaged. You are probably sharing files with SAMBA or CIFS or using ftp to transfer the files from your PC. But the DOS/Windows filesystem is incompatible with other operating systems like Unix. This is because DOS was designed to terminate each line of a plain ASCII file with CR/LF (carriage return and linefeed) while Unix systems use just the LF character. Other operating systems such as mainframes have dozens of incompatible file formats.

So when you edit files on a PC, they look fine on the PC but look strange on HP-UX. But the reverse is also true. Create a simple file on HP-UX and transfer it using ftp binary mode and in Notepad, the file will have little black squares where the next line should be. That's because Notepad expects 2 characters (CR/LF) and not just the LF which is standard for Unix. Note that if you open the file with Wordpad, it will appear correct but that's because Wordpad uses a single LF as a soft-return marker. Other operating systems are even more incompatible.

The good news is that you don't need dos2ux (or ux2dos) to exchange files. ftp has a special option called ASCII which performs the required translation. Your ftp may default to BINARY which does nothing so when transferring text files, override the ftp setting with the ASCII command. This will work correctly between all operating systems.


Bill Hassell, sysadmin