Skip to main content

1E 9.x (on-premises)

FileSystem.GetFileByLine

Method

GetFileByLine

Module

FileSystem

Library

Core

Action

Returns the lines of the given text file(s) matching the supplied regular expression pattern.

Parameters

FilePath (string): The full path of the file. Similar to the GetFile method, the path can include environment variables represented by the local shell format (e.g. %env% on Windows), and wildcards such as '*' for multiple characters and '?' for a single character.

RegExp (string; optional, default: empty string): A regular expression pattern in ECMA-262 ECMAScript format for the lines to match. If not supplied, every line will be returned.

Return values

A maximum of 50,000 lines is returned.

For each line of each file matching the pattern found:

  • FileName (string): The full path, with any wildcards and environment variables expanded.

  • LineNumber (int): The line number, starting at 1.

  • Content (string): The content of the line that contains a match for the regular expression.

Example

Search the ConfigMgr WUAHandler log for any errors.

FileSystem.GetFileByLine(FileName:"c:\\Windows\\CCM\\Logs\\WUAHandler.log", RegExp:"[eE]rror");

By default, the search is case sensitive. Here we are using RexExp to search for both Error and error.

Platforms

  • Windows

  • Linux

  • MacOS

Notes

Do not use on a binary file - the returned Content will probably be corrupted.

A good site to help understand basic regular expressions is https://regexr.com/