I want to capture version number using bigfix analysis which is 1.3.2.1 and that can be dynamic but the
version and /version will remains static and the file location is /tmp/output.txt.
I want to capture version number using bigfix analysis which is 1.3.2.1 and that can be dynamic but the
version and /version will remains static and the file location is /tmp/output.txt.
if windows of operating system then "N/A" else if not exists file "/tmp/output.txt" then "No file" else if exists file "/tmp/output.txt" whose (exists lines whose (it as string as lowercase contains "version" as lowercase) of it) then following texts of firsts "version" of preceding texts of firsts "/version" of lines of file "/tmp/output.txt" as string else "None"
If you have many files with the same content format, you might attempt the following:
if windows of operating system then "N/A" else if not exists files ("/tmp/output.txt";"/tmp/output_1.txt";"/tmp/output_2.txt";"/tmp/output_3.txt") then "No file" else if exists files ("/tmp/output.txt";"/tmp/output_1.txt";"/tmp/output_2.txt";"/tmp/output_3.txt") whose (exists lines whose (it as string as lowercase contains "version" as lowercase) of it) then unique values of following texts of firsts "version" of preceding texts of firsts "/version" of (lines of files ("/tmp/output.txt";"/tmp/output_1.txt";"/tmp/output_2.txt";"/tmp/output_3.txt") as string) else "None"
If you are parsing XML files then an approach using xpaths may be more flexible. See the tutorial from @brolly33 on the BigFix Tech Advisors YouTube channel.
Taking a simple XML format then having copies of it in the /tmp folder with different values for <book> we can parse it with a fairly simple statement
Q: (((it as text) of xpaths "/root/book" of it) of xml documents of it) of files ("output1.txt";"output2.txt";"output3.txt") of folder "/tmp"
A: BigFix 101
A: Compliance 301
A: Relevance 401