Line audit and triming output

(imported topic written by SystemAdmin)

Hi Guys,

I’m new to this and would appreciate your help.

So I have this sample.txt file and wanted to audit the following conditions and value.

  1. If the file exists

  2. The version BUT only showing “1.2.3.4”

expected output would look like this …

Audit Pass - 1.2.3.4

or

Audit Fail - 2.3.4.1

or

Audit Fail - File not found

================

sample.txt

================

John Smith

1.2.3.4

a

b

c

d

e

f

g

================

thanks so much.

(imported comment written by BenKus)

I am a bit confused… does the version 1.2.3.4 mean that it was successful? If so, try this:

q: (if (not exists file “C:\sample.txt”) then “Audit Fail - File not found” else (if exists (lines whose (it as lowercase contains “” AND it contains “1.2.3.4”) of it) then (“Audit Passed -” & following text of first “” of (it as lowercase) of lines whose (it as lowercase contains “”) of it) else (if exists (lines whose (it as lowercase contains “” AND it does not contain “1.2.3.4”) of it) then (“Audit Passed -” & following text of first “” of (it as lowercase) of lines whose (it as lowercase contains “”) of it) else “Version not found”))) of file "C:\sample.txt"
A: Audit Passed - 1.2.3.4

I added an extra part of the relevance to detect if the file has no “” string and report an error…

Ben

(imported comment written by SystemAdmin)

Cool! this is the one i’m looking for thanks again! Btw, have change the second Audit Pass to Audit Fail since I was looking for 1.2.3.4 only. thanks again.

q: (if (not exists file “C:\sample.txt”) then “Audit Fail - File not found” else (if exists (lines whose (it as lowercase contains “” AND it contains “1.2.3.4”) of it) then (“Audit Passed -” & following text of first “” of (it as lowercase) of lines whose (it as lowercase contains “”) of it) else (if exists (lines whose (it as lowercase contains “” AND it does not contain “1.2.3.4”) of it) then (“Audit Fail -” & following text of first “” of (it as lowercase) of lines whose (it as lowercase contains “”) of it) else “Version not found”))) of file “C:\sample.txt”