String Character Length: Difference between revisions

No edit summary
Line 21:
==[[AWK]]==
[[Category:AWK]]
From within any code block:
 
echo w=length("Hello, world!") | awk '{print length($0)}' # static string example
x=length("Hello," s " world!") # dynamic string example
 
y=length($1) # input field example
z=length(s) # variable name example
Ad hoc program from command line:
echo "Hello, world!" | awk '{print length($0)}'
From executable script: (prints for every line arriving on stdin)
#!/usr/bin/awk -f
{print"The length of this line is "length($0)}
 
==[[C]]==
Anonymous user