Find text inside a file - not case sensitive?

Hi,
I have built relevance to search inside a file and look for a certain string of characters. it works great, except it is case sensitive, and I do not want it to be. Unfortunately, the case could be found either all upper, all lower, or mixed case. I want the relevance to find it no matter what the case, but I cannot seem to find the code. Here is the relevance as it stands today, but want to add that case does not matter. . .

exists file “C:\Backup\TSM\baclient\dsm.opt” whose (not exists lines whose (it contains “OracleAgent”)of it )

Thanks in advance!

Try the following (converts the line to lowercase before it looks for the lowercase string in it) …

exists file “C:\Backup\TSM\baclient\dsm.opt” whose (not exists lines whose (it as lowercase contains “oracleagent”) of it )

2 Likes

Do you want your relevance to return machines that do have the file, but don’t have that entry, or do you want it also to return machines that don’t have the file at all?

This should be faster:

not exists files "C:\Backup\TSM\baclient\dsm.opt" whose(contents of it as lowercase contains "oracleagent")

Take a look at these related items for Tivoli Storage Manager:

http://bigfix.me/fixlet/details/2608
http://bigfix.me/analysis/details/2994716
http://bigfix.me/analysis/details/2994591
http://bigfix.me/fixlet/details/829
http://bigfix.me/fixlet/details/686

All of our machines have that file (I did check that using separate relevance just to be sure that part worked). So now I only want to know what machines don’t have the words ‘oracleagent’ in that file (in any case).

It seems in the relevance debugger the code you gave works, but when i put it into a new task, some servers show relevant (as NOT having those words in the file), but when I look at the file, i find those words in there. . . . but not on all of them. Maybe I just need to let it ‘cook’ for a while and check later. Anyway, thanks for your input on this.

You could get odd results if that file is locked by another process.

This relevance will be false if that is the case:

exists lines of files "C:\Backup\TSM\baclient\dsm.opt"

The exists might also give you some interesting results if the file is locked etc. We probably should add something that indicates you can open it. We do try to open a file with the READ_SHARE bits turned on but some applications don’t have the file open in a sharable way or its open for exclusive write.

1 Like

Ah, good to know Alan, thank you!

But that doesn’t explain why I can open a file in Notepad++ that the BES Client will not read. Couldn’t the BES Client just do the same as Notepad++ ?

There are cases that aren’t covered yes. If a file is open WRITE_SHARED we currently don’t open it as the contents are changing. Its a topic for discussion and something that would be nice to get around.

I don’t believe even Notepad++ though can open a file that is opened for exclusive write though.

1 Like

I get the sense that Notepad++ copies the file into RAM before opening it, so it may, but I’m not certain.

Seems like the BES Client could do the same for files up to a maximum size.

A post was split to a new topic: Finding text in file lines