1

次のコードの出力を教えてください。

egrep -v '.*:\*|:\!' /etc/shadow |awk -F: '{print $1}'
4

5 に答える 5

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 .

パスワード フィールドには、行が出力する暗号化されたパスワードが含まれています。

于 2014-04-21T12:12:01.447 に答える
1

egrepここで使用する必要はまったくありませんawk。すべて実行できます。

awk -F: '$2!~/[*!]/ {print $1}' /etc/shadow

そして、他の人が指摘しているように、このリストには、2番目のフィールドに含まれてい*ないすべてのユーザーが含まれています。 これにより、すべてのユーザーにパスワードが付与されます。!

于 2014-04-21T15:11:21.743 に答える