Sorry for If I look stupid asking this question, but I am very curious to know about it.
I wanted to simply calculate the length of a string (that is hash value). So, I opened terminal and did this:
$ apropos length
that returned me with a bunch of commands/functions having (3)
or (3ssl)
appended at the end of them. Now man man gives us information about what these section numbers
mean.
3 Library calls (functions within program libraries)
Out of curiosity, I just tried with all these commands (in hope at least one would work)
strcspn (3) - get length of a prefix substring
strlen (3) - calculate the length of a string
strnlen (3) - determine the length of a fixed-size string
strspn (3) - get length of a prefix substring
wcslen (3) - determine the length of a wide-character string
wcsnlen (3) - determine the length of a fixed-size wide-character string
and got nothing but same error for every command
$ strnlen HelloWorld
$ strnlen: command not found
Well, I know how to find length of string in shell using wc -m
, expr length
and other workarounds.But,
Is it possible to write a bash script that can internally call these library commands and get the task done ?