exec 3<binary.file # open the file for reading on file descriptor 3
IFS= #
read -N1 -u3 num char # read 1 character into variable "num""char"
# to obtain the ordinal value of the char "char"
num=$(printf %s "$char" | od -An -vtu1 | sed 's/^[[:space:]]*//')
read -N$num -u3 str # read "num" chars
exec 3<&- # close fd 3
glenn jackman
- 88.5k
- 16
- 124
- 179