Important This documentation space contains information about PATROL Agents when deployed in a TrueSight Operations Management environment. If you are a BMC Helix Operations Management user, see PATROL Agent 22.3.01 for BMC Helix Operations Management.

nthlinef()


Return specified lines from a text string.

Syntax

nthlinef(text,lines,[separator])

Parameter

Parameter

Definition

text

text to be separated into lines by the nthlinef() function The text can be a text string enclosed in double quotes, or one or more PSL commands that produce text as output.

lines

integer list specifying the line numbers nthlinef() should look for in text*Valid Values* 
x,y line x and line y 
x-y all lines from x to y inclusive 
-x all lines from 1 to x inclusive 
x- all lines from x to EOF character inclusive

separator

optional character that should be placed between each field of nthlinef() output*Default* 
new-line character (\n)

Description

The nthlinef() function returns the lines of text separated by new-line characters. If you specify a separator, thenthlinef() function will use separator to separate lines.

Note

The difference between the nthlinef() and nthline() functions is as follows:

  • 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 recommends you to 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 the top five processes
print(nthlinef(system("ps -eaf"),"2-6"));

The following example illustrates the difference between the nthlinef() function and the nthline() function:

 

string = "abc\n\n123\nxyz";
A = nthline(string,3);
B = nthlinef(string,3);
print("nthline() 3rd string argument is : ",A,"\n");
print("nthlinef() 3rd string argument is : ",B,"\n");

 

 

 

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*