mercredi 3 février 2021

How to use grep command in a if else statement for audit automation in bash?

I have to write a bash script to check if the sudo log file exists in Centos Linux. The grep command to be used is

grep -Ei '^\sDefaults\s+([^#]+,\s)?logfile=' /etc/sudoers /etc/sudoers.d/*

If the logfile exists the output would be Default logfile = "the location" or else "No such file or directory"

So I need to use an if-else statement and echo out if there is compliance or non-compliance. This is what I have got so far. How do I make this better?

Aucun commentaire:

Enregistrer un commentaire