String length: Difference between revisions

m
→‎{{header|UNIX Shell}}: Add note about bytes vs characters in implementations
(→‎Joy: add)
m (→‎{{header|UNIX Shell}}: Add note about bytes vs characters in implementations)
Line 3,612:
 
=={{header|UNIX Shell}}==
====Byte Lengthlength via external utility:====
====With external utility:====
 
{{works with|Bourne Shell}}
Line 3,621 ⟶ 3,620:
 
====With [[Unix|SUSv3]] parameter expansion modifier:====
 
This returns the byte count in ash/dash, but the character count in bash, ksh, and zsh:
 
{{works with|Almquist SHell}}
{{works with|Bourne Again SHell|3.2}}
{{works with|pdksh|5.2.14Korn 99/07/13.2Shell|93}}
{{works with|Z SHell}}
<syntaxhighlight lang="bash">string='Hello, world!'
length="${#string}"
echo $length # if you want it printed to the terminal</syntaxhighlight>
 
1,480

edits