Middle three digits: Difference between revisions
Content deleted Content added
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 |
||
{ |
{ |
||
typeset -i n="${1#-}" |
|||
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" |