Relevance to get version number from a file

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.

Pls see the below content.

?xml version=“1.0” encoding="UTF
DOCTYPE product SYSTEM “product.dtd”
BASE</id
version1.3.2.1/version
build-info
date=“1/1/23”
level=“12345”/

@gsing1987 your question seems incomplete, could you please update it & describe what you are up to.

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.

Pls see the below content.

?xml version=“1.0” encoding="UTF
DOCTYPE product SYSTEM “product.dtd”
BASE</id
version1.3.2.1/version
build-info
date=“1/1/23”
level=“12345”/

Try this:

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"

(post deleted by author)

Thanks it is working, can you pls advise how I can add multiple file path in single analysis your have shared.

Why do you want to do that? Are these multiple files carrying the same thing and format?

Yes, File path is different so need to add those path in the analysis.

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

<?xml version="1.0" encoding="UTF-8"?>
<root>
	<book>Relevance 401</book>
	<author>HCL Tech</author>
	<location>online</location>
</root>
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
3 Likes