problem with dos2unix command

hi friends i am using the dos2unix command to remove the ^M characters coming at the end of each line , but i getting the folowing message:

 > dos2unix file.sql
could not open /dev/kbd to get keyboard type US keyboard assumed
could not get keyboard type US keyboard assumed
---------file content-------
---------------------------

can anyone help!!!
thanks in advance

>uname -a
SunOS spdma544 5.10 Generic_142909-17 sun4u sparc SUNW,SPARC-Enterprise

This is asked very often - you can use the search function of the forum to get a solution/alternative.
Not sure why your dos2unix complains, but you can try this:

tr -d '\015' < winfile > unixfile
1 Like

when i am using the above cmd i am getiing the following message

tr -d '\015' y.sql x.sql 
Usage: tr [ -cds ] [ String1 [ String2 ] ]

:frowning:

Hi

It has to be like Zaxxon mentioned:

tr -d '\015' <y.sql >x.sql

Guru.

1 Like

hey sorry its working but what if i want to keep the same file name

 
@:        > tr -d '\015' < y > y
 

its generating an empty y file.

Hi

Re-direct the output to a temporary file, and then rename the file to the original one:

tr -d '\015' <y.sql >x.sql
mv x.sql y.sql

Guru

1 Like

i checked with the below command, its working:

 > dos2unix file.sql file.sql

previously i was not giving the target filename with the dos2unix command

thanks for your time