I want to match certain lines composed of three patterns with the possibility for the user to supply them. If the patterns are not supplied by the user, they are defaulted. However the last pattern is optional.
Have written the following awk script
Code:
BEGIN {
display = 0
if (ukingd == "") ukingd="([[:graph:]]+)"
if (uclass == "") uclass="([[:graph:]]+)"
if (ufamil == "") ufamil="([[:print:]]*)"
}
match($0, beg_ere, maggr) {
if ( ! ufamil ) { display = 1 } # <== problem
else { do_something }
}
display { sub(km_ere, " ") ; print }
But I have a problew (shown above). I want to set display = 1 when the user does not supply a pattern for ufamil. But because I default its value, the default makes the script think that it was user supplied.