Tuesday 6 August 2019

AWK: the substr command to select a substring


Under Linux, the awk command has quite a few useful functions. One of them, which is called substr, can be used to select a substring from the input.
Here is its syntax:
substr(s, a, b) : it returns b number of chars from string s, starting at position a. The parameter b is optional, in which case it means up to the end of the string.
For instance, consider a file with the following content:
Let us save this data into a file called data.txt
Then, here are a few case examples:

0 comments:

Post a Comment