Next: , Previous: , Up: system group   [Contents][Index]


19.2.4 Inspecting entries from /etc/group

The following functions inspect entries from /etc/group using an index argument; we must obtain indexes with the functions described in Searching entries from /etc/group.

Function: mbfl_system_group_get_name group_idx
Function: mbfl_system_group_get_name_var _RV group_idx

Print to stdout the field name of the /etc/group entry at index group_idx.

The function variant _var stores the result in the variable _RV, rather than print it; Result variables.

local IDX NAME

mbfl_system_group_read
if mbfl_system_group_find_entry_by_name_var IDX root
then
    if mbfl_system_group_get_name_var NAME $IDX
    then echo "$NAME"
    fi
fi
Function: mbfl_system_group_get_passwd group_idx
Function: mbfl_system_group_get_passwd_var _RV group_idx

Print to stdout the field passwd of the /etc/group entry at index group_idx.

The function variant _var stores the result in the variable _RV, rather than print it; Result variables.

Function: mbfl_system_group_get_gid group_idx
Function: mbfl_system_group_get_gid_var _RV group_idx

Print to stdout the field gid of the /etc/group entry at index group_idx.

The function variant _var stores the result in the variable _RV, rather than print it; Result variables.

Function: mbfl_system_group_get_users group_idx
Function: mbfl_system_group_get_users_var _RV group_idx

Print to stdout the field users of the /etc/group entry at index group_idx.

The function variant _var stores the result in the variable _RV, rather than print it; Result variables.

Function: mbfl_system_group_get_users_count group_idx
Function: mbfl_system_group_get_users_count_var _RV group_idx

Print to stdout the number of user names in the list of users for the entry at index group_idx.

The function variant _var stores the result in the variable _RV, rather than print it; Result variables.

Function: mbfl_system_group_get_user_name group_idx user_idx
Function: mbfl_system_group_get_user_name_var _RV group_idx user_idx

Print to stdout the name of the user at index user_idx in the list of users for the entry at index group_idx.

The function variant _var stores the result in the variable _RV, rather than print it; Result variables.

local -i GROUP_IDX USER_COUNT USER_IDX
local USER_NAME

mbfl_system_group_read

if GROUP_IDX=$(mbfl_system_group_find_entry_by_name root)
then
    USER_COUNT=$(mbfl_system_group_get_users_count $GROUP_IDX)
    for ((USER_IDX=0; USER_IDX < USER_COUNT; ++USER_IDX))
    do mbfl_system_group_get_user_name $GROUP_IDX $USER_IDX
    done
fi

# Using the "_var" variants.
if mbfl_system_group_find_entry_by_name_var GROUP_IDX root
then
    mbfl_system_group_get_users_count_var USER_COUNT $GROUP_IDX
    for ((USER_IDX=0; USER_IDX < USER_COUNT; ++USER_IDX))
    do
        mbfl_system_group_get_user_name_var USER_NAME \
           $GROUP_IDX $USER_IDX
        echo "$USER_NAME"
    done
else return 1
fi

Next: , Previous: , Up: system group   [Contents][Index]

This document describes version 3.0.0-devel.0 of Marcos Bash Functions Library.