Originally posted by: apeasecpc
Since AIX does not have the dtox or xtod commands provided in other types of UNIX, I created simple awk scripts to replicate them.
dtox:
#!/bin/ksh
#dtox
awk '{T=$0;if(length($0)>0) {if((substr($0,length($0),1)=="\r")&&(length($0)>1))
T=substr($0,1,length($0)-1);if((substr($0,length($0),1)=="\r")&&(length($0)==1)
) T="";}printf("%s\n",T);}' $1
xtod:
#!/bin/ksh
#xtod
awk '{T=$0;if(length($0)>0) {if((substr($0,length($0),1)=="\r")&&(length($0)>1))
T=substr($0,1,length($0)-1);if((substr($0,length($0),1)=="\r")&&(length($0)==1)
) T="";}printf("%s\r\n",T);}' $1
=>dtox {source} >{destination) - strips ^M character
=>xtod {source} >{destination} - adds ^M character back in
#AIX-Forum