Middle three digits: Difference between revisions

Content deleted Content added
Markjreed (talk | contribs)
Markjreed (talk | contribs)
Line 807: Line 807:
=={{header|UNIX Shell}}==
=={{header|UNIX Shell}}==
{{works with|Bourne Again Shell}}
{{works with|Bourne Again Shell}}
{{works with|Korn Shell|93}}
{{works with|Z Shell}}

<lang bash>function middle3digits
<lang bash>function middle3digits
{
{
local -i n="${1#-}"
typeset -i n="${1#-}"
local -i l=${#n}
typeset -i l=${#n}
if (( l < 3 )); then
if (( l < 3 )); then
echo >&2 "$1 has less than 3 digits"
echo >&2 "$1 has less than 3 digits"