Is there a dos2unix command in HP? (1945 Views)
Reply
Occasional Visitor
Connie L
Posts: 1
Registered: ‎03-07-2000
Message 1 of 6 (1,945 Views)

Is there a dos2unix command in HP?

I'm trying to find a command in HP that will convert a dos file to unix by
removing the ^M's in the file - similiar to the dos2unix command in sun.

If anyone knows of such a command in HP, please let me know. I really
appreciate it.

Thanks,
Connie
Regular Advisor
Alan Riggs_1
Posts: 100
Registered: ‎10-21-1999
Message 2 of 6 (1,945 Views)

Re: Is there a dos2unix command in HP?

If all you need to do is remove the "^M" at the end of lines, use:

sed 's/^M//' infile > outfile

"^M" is generated by (ctrl-v, ctrl-m)
Occasional Visitor
Tom Mueller
Posts: 1
Registered: ‎03-08-2000
Message 3 of 6 (1,945 Views)

Re: Is there a dos2unix command in HP?

We made this script whith ed:

#!/usr/bin/sh
PATH=/usr/bin; p0=${0##*/}
v=; [[ "$1" = -v ]] && { v=.; shift;}
[[ $#.$p0 != 1.d2u && $#.$p0 != 1.u2d ]] &&
{ cat <<-. >&2
End-of-line style direct file converter - using ed (DOS<->UX formats)

Usage: d2u [-v] {file} to convert DOS->UX (CR+LF->LF)
u2d [-v] {file} to convert UX->DOS (LF->CR+LF)

-v for verbose output (echoes # of lines)
.
exit 2;}
[[ ! -f $1 || ! -r $1 || ! -w $1 ]] &&
{ cat <<-. >&2
$p0 -- $1 not regular+readable+writable:
$(ls -ld $1 2>&1)
.
exit 1;}
a=$(grep -c "^M$" $1); l=$(wc -l <$1)
[[ $l = 0 ]] && { [[ -n $v ]] && echo "$p0 -- $1: no lines"; exit 0;}
if [[ $p0 = u2d ]] ; then
if [[ $a != 0 ]] ; then
x=already; [[ $a != $l ]] && x=partially
echo "$p0 -- $1 $x in DOS-format">&2; exit 1
fi
s=DOS; echo "1,\$s/\$/^M/\nw\nq"|ed -s $1; e=$?
else # [[ $p0 = d2u ]]
[[ $a = 0 ]] && { echo "$p0 -- $1 already in UX-format">&2; exit 1;}
s=UX; echo "1,\$s/^M\$//\nw\nq"|ed -s $1; e=$?
fi
[[ $e = 0 && -n $v ]] &&
{ v=s; [[ $l = 1 ]] && v=; echo "$p0 -- $1: $l line$v ($s-format)";}
exit $e
Occasional Visitor
Claire Ruben_1
Posts: 1
Registered: ‎03-08-2000
Message 4 of 6 (1,945 Views)

Re: Is there a dos2unix command in HP?

Hello,

I believe the command you're looking for is /usr/bin/dos2ux.

Regards,
Claire Ruben
Regular Advisor
Melvyn Burnard_1
Posts: 130
Registered: ‎11-30-1999
Message 5 of 6 (1,945 Views)

Re: Is there a dos2unix command in HP?

If you do :

swlist -l product | grep DOS

you should see the following if you have the MSDOS utilities installed::

MSDOS-Utils B.10.20 MSDOS-Utils

If so, then there are various dos commands that will help you, including the
dos2ux command.
Occasional Contributor
Alan Bocutt
Posts: 6
Registered: ‎03-09-2000
Message 6 of 6 (1,945 Views)

Re: Is there a dos2unix command in HP?

If all you are having a problem with is the ^M's another solution would be to
transfer your text files as binary then there are no ^M in the file anyway
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.