nthline()
Return specified lines from a text string.
Syntax
Parameter
Parameter | Definition |
---|---|
text | text to be separated into lines by the nthline() function The text can be a text string enclosed in double quotation marks, or one or more PSL commands that produce text as output. |
lines | integer list specifying the line numbers nthline() should look for in text *Valid Values* |
separator | optional character that should be placed between each field of nthline() output *Default* |
Description
The nthline() function returns the lines of text separated by new-line characters. If you specify a separator, the nthline() function will use separator to separate lines.
- The nthlinef() function treats each new-line character as a line.
- The nthline() function treats only a nonempty line (that is, a line with a nonnew-line character preceding a new-line character) as a line.
BMC Software recommends you use nthlinef() function to be consistent with other PSL functions.
Example
The following PSL script prints the top five processes executing on a Unix system.
print(nthline(system("ps -eaf"),"2-6"));
The following example illustrates the difference between the nthline() function and the nthlinef() function:
A = nthline(string,3);
B = nthlinef(string,3);
print("nthline() 3rd string argument is : ",A,"\n");
print("nthlinef() 3rd string argument is : ",B,"\n");