getent

来自「Axis 221 camera embedded programing inte」· 代码 · 共 50 行

TXT
50
字号
#!/bin/sh# $Header: /usr/local/cvs/linux/libs/uClibc/extra/scripts/getent,v 1.1.1.1 2005/01/24 11:50:39 aurer Exp $search_entry() {  if [ -e "$1" ] ; then    /bin/egrep -v "^#" $1 | /bin/sed 's/#.*$//' | /bin/egrep "${string}" | /bin/sed -n 1p    retval=$?    [ "$retval" = 0 ] || retval=2  else    retval=2  fi}file="/etc/$1"string="dummy"#aliases|ethers|group|hosts|netgroup|networks|passwd|protocols|rpc|services|shadow)# dns based search is not supported for hosts|networks# networks searches ^string# protocols|rpc|services searches string anywhere# ethers|netgroup ?# it returns only the first matchcase $1 in  group|passwd|shadow)    string="^\<$2\>:"    ;;  aliases)    if [ -f /etc/postfix/aliases ] ; then      file="/etc/postfix/aliases"    elif [ -f /etc/mail/aliases ] ; then      file="/etc/mail/aliases"    fi    string="^\<$2\>:"    ;;  networks)    string="^\<$2\>"    ;;  hosts|protocol|rpc|services)    string="\<$2\>"    ;;  *)    echo "Unknown database: $1"    exit 1    ;;esacsearch_entry $file $2exit $retval

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?