Here is the input:

*           true, false, yes, no, always, never.
    su = true
    maxexpired = -1
    umask = 077
    expires = 0

    su = true

and I only need this output:


So I only need the "umask = 077" line for the default user. This is a snippet from /etc/security/user. "grep -p" doesn't works, because there isn't any empty line before "default:". I googled for awk record separators, but didn't found out how to do this. How can I do this? ( "..." are just other attributes.. )

UPDATE: updated the input template, Thanks

2 Answers 2


This works (code edited to get the value for only the default user):

awk -F'= ' '/default:/,/umask =/{ if(/umask =/){ print $2 } }' /etc/security/user

-F sets the input field separator. The code matches lines with umask = in them and prints their second fields.


to pick up the umask value only for the default user

awk '/default:/,/umask/{if ($0 ~ /umask/){split($0, arr, "="); print(arr[2])}}' input 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .