Usage: chr.bsh [-D] <-d> <-h|-x> <-b> [-H] <char> [<-a> <code>]
<char> A valid ascii code value: character, decimal,
hexadecimal, octal (0o000 or \000)
OPTIONS:
-d Convert character to decimal
-a Convert code (hex, octal) to ascii character
-h|-x Convert character to hexadecimal
-b Convert character to binary
-o Convert character to octal
-H Show help message
-D Turn on debug mode
-? Show usage
## Options may be duplicated and compounded in any order
$ chr.bsh A -d
65
$ chr.bsh A -d -b
01000001
$ chr.bsh A -d -b -x
0x41
$ chr.bsh A -d -b -x -o
0o101
$ chr.bsh A -d -b -x -o -b
01000001
$ chr.bsh A -d -b -x -o -b -h
0x41
$ chr.bsh A -d -b -x -o -b -h -a
A
## Experimentally - it supports pipes and redirects!
$ echo A | chr.bsh -d -b
01000001
$ chr.bsh -d -b -x <<< A
0x41
## Multiple characters from a string!
$ echo DEF | chr.bsh -d -b
01000100
01000101
01000110
$ chr.bsh -d -b -o <<< XYZ | chr.bsh -a
XYZ
Thursday, March 26, 2015
Bash CHR program
Bash script that takes ascii code value - character, hexadecimal or octal - and returns corresponding representation:
https://github.com/AdamDanischewski/chr.bsh
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment