次のコードの出力を教えてください。
egrep -v '.*:\*|:\!' /etc/shadow |awk -F: '{print $1}'
説明 :
egrep - Search the pattern with using regular expression
-v - Invert of matching pattern that mean matched pattern will not executed
'.*:\*|:\!'- That mean Any character and colon occur then the exact * found not
any charater of star ( For example User only password maintain
other than password field contain * .
awk -F: - Set the delimiter is ":"
'{print $1}' - print the first column .
パスワード フィールドには、行が出力する暗号化されたパスワードが含まれています。
egrep
ここで使用する必要はまったくありませんawk
。すべて実行できます。
awk -F: '$2!~/[*!]/ {print $1}' /etc/shadow
そして、他の人が指摘しているように、このリストには、2番目のフィールドに含まれてい*
ないすべてのユーザーが含まれています。
これにより、すべてのユーザーにパスワードが付与されます。!