Generating Octal/Hex Codes from Bourne Shell

Wietse Venema wietse at wzv.UUCP
Tue Aug 23 08:10:51 AEST 1988


In article <2848 at quacky.mips.COM> dce at quacky.UUCP (David Elliott) writes:
}In article <1054 at marconi.SW.MCC.COM> knutson at marconi.sw.mcc.com.UUCP (Jim Knutson) writes:
}>Well, one way to do it would be to use the tr command.  For instance,
}>to repeat your examples:
}
}>		echo . | tr . '\007'	# 0x07
}
}This is a very useful trick.
}
}One thing it doesn't handle is generating a NUL.  I've tried all
}kinds of things, but have never found a way to generate a NUL

It depends on what you need the null character for. For example, 

	echo . | tr . '\200'

is usually ok for output to ttys, since ordinary tty drivers strip
the eigth bit (except when in raw mode, of course).
-- 
					Wietse Venema

uucp:	mcvax!eutrc3!wswietse	| Eindhoven University of Technology
bitnet: wswietse at heitue5	| 5600 MB Eindhoven, The Netherlands



More information about the Comp.unix.wizards mailing list