{ if (( $1 == "login" || $1 == "other" ) && $2 == "auth" ) { add = "yes" service = $1 } } /^#/ { if ( add == "yes" ) { add = no print service, "auth binding pam_unix_auth.so.1 server_policy" print service, "auth required pam_ldap.so.1" } } /other.*auth.*required.*pam_unix_auth.so.1/ { $3 = "sufficient" } {print}