Hi, I know the blog is so old but my question is related to it.
lines whose (it as string contains “abc” ) of files “test.txt” of folders “C:\temp”
the test.txt file has these values
abc
abc_123
abc_567
I get all the three lines but I need to get the abc only, exact match to what I added in the relevance. I replaced contains with equal but that didn’t work may be it is for Integer.
lines whose (it as string = "abc" ) of files "test.txt" of folders "C:\temp"
Note the match is both case-sensitive and space-sensitive. If there is whitespace before or after “abc” then the line will not match. If the line is in mixed-case i.e. ‘Abc’ or ‘ABC’ then it will not match.
We might strip off leading/trailing whitespace via the ‘trimmed string’ inspector; and perform a case-insensitive match by casting both operators ‘as lowercase’. To to both -
lines whose (it as string as trimmed string as lowercase = "abc" as lowercase) of files "test.txt" of folders "C:\temp"
Hi Jason,
One more question regarding this. In the above relevance I got the line in the file
ConnectionStringTrue1
We actually wanted to find out if the value is True or False in that configuration file. Now, I want to replace the file to value False on machines that have value True.
Is there a way to create a relevance to push the replace file fixlet to only those machines having value True in that line? something like this
exists value true of lines whose (it as string as lowercase contains “connectionString” ) of files “config.txt” of folders “C:\Program Files (x86)\program”
I think that would just change your line matching condition?
exists lines whose (it as string as lowercase contains "ConnectionStringTrue1" as lowercase) of files "config.txt" of folders “C:\Program Files (x86)\program”
Thank you Jason.
Again this was the issue with Spaces. In Bigfix column it was showing ConnectionStringTrue1 all together and when I run it on debugger, I got Connection%09%09%09String%09%09%True%09%09%1%09.
I used the debugger result in your script and it worked fine. Thanks again for your help.
As @Aram points out, the “%09” refers to TAB (the ASCII code of 0x09 is the TAB character).
If you were unsure about the spacing in the file, you could run the query with all three match conditions expanded, as
exists lines whose (it as string as lowercase contains "ConnectionString" as lowercase and it as lowercase contains "true" as lowercase and it contains "1") of files "config.txt" of folders "C:\Program Files (x86)\program"
Thanks both of you for your input. That makes perfect sense. @JasonWalker the script that you sent now also worked fine. I will use this one because we never know maybe on some machines the tabs and spaces are different in the file. Much appreciated for your support.
This actually reminds me something that I have always wondered in similar context - is there any performance advantage to scan through all lines: lines whose (it starts with "....") of file "path"
It’s pretty clear that the former is expensive and you need to be quite aware of the size of file you are trying it on but it is not immediately clear how the former works and whether it is any better performance-wise?