Generating Octal/Hex Codes from Bourne Shell
Leo de Wit
leo at philmds.UUCP
Fri Aug 19 06:48:20 AEST 1988
In article <118 at gillxp> rg at gillxp (Richard J. Gill) writes:
>I have the need be able to generate the full ASCII character
>set from the Bourne shell. There is no problem on my NCR Tower
>XP (System V); I simply use the following syntax:
>
> echo "\007" # 0x07
> echo "\0212" # 0x8a
> ...
>
>On my Fortune 32:16 (Forpro 2.0 - Sys 3v7 & BSD 4.3), however,
>the string is simply displayed as a literal. Any ideas on how I
>can generate the fully ASCII set from the Bourne shell on the
>Fortune?
On BSD you can use tr(1) which understands octal codes just in the
way your echo does in System V; the two examples could be rewritten
as:
tr a "\007" <<EOT
a
EOT
tr a "\0212" <<EOT
a
EOT
The a character acts as a dummy and is translated to the octal coded
character. If you use these characters a lot, it would make sense to
save the output of tr into shell variables.
Hope this helps?
Leo.
More information about the Comp.unix.wizards
mailing list