Details
-
Type:
Story
-
Status: Done
-
Priority:
(None)
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 3.18.0
-
Component/s: None
-
Labels:
-
Story Points:0
Description
Currently, (as of 3.17.0) printfile bodies can be used to report the contents of a file from the top of the file, but there is not yet a way of printing the last several lines of a file. For example:
bundle agent example_printfile(file) { reports: "The first two lines of '$(file)':" printfile => head_n( $(file), 2 ); "The full content of '$(file)'" printfile => cat( $(file) ); } bundle agent __main__ { methods: "Print Self" usebundle => example_printfile($(this.promise_filename)); }
Outputs:
R: The first two lines of '/home/nickanderson/org/cfengine3-gPoHAy': R: body file control{ inputs => { '$(sys.libdir)/stdlib.cf' };} R: bundle agent example_printfile(file) R: The full content of '/home/nickanderson/org/cfengine3-gPoHAy' R: body file control{ inputs => { '$(sys.libdir)/stdlib.cf' };} R: bundle agent example_printfile(file) R: { R: reports: R: "The first two lines of '$(file)':" R: printfile => head_n( $(file), 2 ); R: R: "The full content of '$(file)'" R: printfile => cat( $(file) ); R: } R: bundle agent __main__ R: { R: methods: R: "Print Self" R: usebundle => example_printfile($(this.promise_filename)); R: }
It would be nice if I could specify number_of_lines as a negative number, to print the end of the file, or perhaps a new body attribute to select a number of lines from the start or the end of the file.
Attachments
Issue Links
- relates to
-
CFE-3642 Stop testing masterfiles against 3.10 binaries
-
- Done
-