跳轉到內容

Fedora 和 Red Hat 系統管理/Awk 指令碼

來自華夏公益教科書

Awk - 一種資料驅動的程式語言

[編輯 | 編輯原始碼]

正在建設中

在命令列使用 Awk

[編輯 | 編輯原始碼]

正在建設中

Awk 指令碼

[編輯 | 編輯原始碼]

從 `passwd` 資料中解析使用者資訊

[編輯 | 編輯原始碼]

/usr/local/bin/bash-users.awk

#!/bin/awk -f
BEGIN {
    FS = ":"
    USER_COUNT = 0
}

/:\/bin\/bash$/ {
    ++USER_COUNT
    print $1
}

END {
    print USER_COUNT " bash users."
}

用法

[user@station user]$ getent passwd | bin/bash-users.awk
root
jkupferer
mesa
user
4 bash users.
華夏公益教科書