How to check a string in a file with not_if guard interpreator?


is their any way so i can check a not_if “findstr root abc.txt”


You could use ruby to check the contents of a file

not_if { ::File.readlines(abc.txt).grep(/root/i).empty? }

Or a more powershell way, assuming findstr returns proper boolean values

powershell_script 'foo' do
  guard_interpreter :powershell_script
  convert_boolean_return true
  not_if "findstr root abc.txt"


can i give #{path}

not_if { ::File.readlines(#{path}).grep(/root/i).empty? }

like this
beacuse i want to use it in a package resource.