March 2018
Beginner to intermediate
416 pages
9h 24m
English
The length (string) function is used to calculate the length of a string. If the string is a number, the length of the digits in the string representing the number is returned—for example:
$ vi length1.awkBEGIN { print "Example of length calculation of string" print "length(hello..!) : " length("hello..!") print "Example of length calculation of number" print "length(10*20) : " length(10*20)
}$ awk -f length1.awk
The output of the execution of the previous code is as follows:
Example of length calculation of stringlength(hello..!) : 8Example of length calculation of numberlength(10*20) : 3
If no argument is given to the length function, then it returns the length of $0. For example, we can use the length function ...
Read now
Unlock full access