dylanaraps / pure-bash-bible

📖 A collection of pure bash alternatives to external processes.
MIT License
36.53k stars 3.28k forks source link

add chr() and ord() #72

Open neuhaus opened 5 years ago

neuhaus commented 5 years ago

ord is usually handled by the external "od" command.

chr() {
  [ "$1" -lt 256 ] || return 1
  printf "\\$(printf '%03o' "$1")"
}

ord() {
  LC_CTYPE=C printf '%d' "'$1"
}

Source