finduser.sh

来自「CMVC是IBM和许多跨国公司的缺陷管理工具。这里给出了很多在Linux下用KS」· Shell 代码 · 共 130 行

SH
130
字号
#!/bin/ksh## SAMPLE NAME: findUser## FUNCTIONS:   This shell script finds user information based on part of the#              user's name.  It will perform a fuzzy search for the user based#              on the part of the user's name that is provided.  For example,#              if you want to find the id for a person with the last name of#              Smith, you would enter :  findUser smith#              The result will be a list of users who have Smith as parth of#              their name.## USAGE:       findUser userName## ENVIRONMENT# VARIABLE(S): CMVC_FAMILY [CMVC_BECOME]## ORIGINS:     27## 5765-039 (C) COPYRIGHT International Business Machines Corp. 1991,1993# 5765-207 (C) COPYRIGHT International Business Machines Corp. 1993# 5765-202 (C) COPYRIGHT International Business Machines Corp. 1993# 5622-063 (C) COPYRIGHT International Business Machines Corp. 1993# 5765-069 (C) COPYRIGHT International Business Machines Corp. 1991,1993# All Rights Reserved# Licensed Materials - Property of IBM## US Government Users Restricted Rights - Use, duplication or# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.###           NOTICE TO USERS OF THE SOURCE CODE EXAMPLES## INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THE SOURCE CODE# EXAMPLES, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS, "AS IS" WITHOUT# WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT# LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A# PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE# OF THE SOURCE CODE EXAMPLES, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS,# IS WITH YOU.  SHOULD ANY PART OF THE SOURCE CODE EXAMPLES PROVE# DEFECTIVE, YOU (AND NOT IBM OR AN AUTHORIZED RISC System/6000* WORKSTATION# DEALER) ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR# CORRECTION.## * RISC System/6000 is a trademark of International Business Machines#   Corporation.## /usr/lpp/cmvc/samples/findUser#if [ $# -eq 0 ]; then        echo "\nusage: $0 userName\n"        echo "This sample shell script finds user information based on part"        echo "of the users name.  It will do a fuzzy search for the user"        echo "based on the part of the user's name that is provided.\n"     exit 1fiif [ -z "$CMVC_FAMILY" ]then  echo "The CMVC family must be set with the CMVC_FAMILY environment variable."  exit 1fitypeset cmd_end='"   -c 20,10 'typeset cmd_front='Report -g "Users U" -select "U.name,U.login,U.area,U.address" -wh "name like  '#typeset cmd_string# Define files to be used and constant strings.NAMELIST=/tmp/bldlst#--------------------------------------------------------------+# For the SUN platform, we need to use nawk instead of awk.    |#--------------------------------------------------------------+UNAME=`uname`export UNAMEcase "$UNAME" inSunOS)	AWK=/usr/bin/nawk	;;*)	AWK=/usr/bin/awk	;;esacexport AWK# Make the parameter not case sensitive. Two copies of the string passed# in are made. One all uppercase the other all lowercase. These are then# piped to an awk script that creates three names to be searched for in# the database. One is all uppercase, the second is all lowercase# and the third is the first letter of the string capitalized and the# rest of the string in lowercase.typeset -i count=1echo $(echo $1 | tr '[a-z]' '[A-Z]')$(echo $1 | tr '[A-Z]' '[a-z]') |$AWK 'BEGIN { RS = "\n"      }      {        uppercase = substr($0, 1, length($0)/2)        lowercase = substr($0, length($0)/2 + 1, length($0)/2)        {printf("%%%s%% \n", uppercase)}        {printf("%%%s%% \n", lowercase)}        {printf("%%%s%s%% \n", substr(uppercase, 1, 1), substr(lowercase, 2,        length(lowercase)-1))}       }' > $NAMELISTexec 3< $NAMELISTwhile read -ru3 namedo    if ((count == 1))      then        cmd_string="'$name'"      else       cmd_string="`print $cmd_string `  or  name like '$name' "    fi     #((count == 3 )) && typeset comb_end=`echo $cmd_string$cmd_end`     count=count+1done exec 3<&-#<$NAMELISTeval "$cmd_front$cmd_string$cmd_end" # Clean up files created by this script[ -r $NAMELIST ] && rm -f $NAMELIST

⌨️ 快捷键说明

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