如何使用Inspec test检查文件的第一行是否包含某个字符串?目前,我正在做这件事。
describe file ('/path/to/file/filename')do
it { should exist }
its('content') { should match 'build/path/location' }
end
end我如何才能更好地不检查整个内容,而只检查第一行?
发布于 2020-08-11 18:18:41
要检查文件内容(例如: rsyslog.conf)所在位置的内容应为*.=/var/log/debug.log
然后,下面的模块将帮助您测试它。
control "rsyslog-1-2-2" do
impact 1.0
desc "Checking Inside rsyslog configuration File & checking the Application Logs Conf. has been set it up."
describe file("/etc/rsyslog.conf") do
its('content') { should match(%r{^\*.=debug\s.*?/var/log/debug.log}) }
end
endhttps://stackoverflow.com/questions/61356701
复制相似问题