为什么要在部门内推广Bash 函数库?主要有两个原因

1、能在用户启动文件(.profile)中配置,并用户登录后启动,然后就能直接使用函数作为命令扩展了;且 能借助bash 的按tab补全,直接在unix/linux下使用。
如:
$cat > fun.sh #编写一个函数:
function get_tp() {  ## GetTopProcess
        ps  -eo "pcpu,pmem,etime,args" |sed '1d'|sort -t. -n -r|head -10
}
$source com.sh #生效
$get_tp
 0.6   0.0       43:34 /home/test/oam/bin/oamAgent_alm 0 0 104
 0.1   0.0 85-01:42:19 /usr/sbin/syncd 60
 0.1   0.0 85-01:23:15 /TimesTen/tt1121/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000003 -facility user
 0.1   0.0 85-01:23:15 /TimesTen/tt1121/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000002 -facility user
 0.1   0.0 85-01:23:15 /TimesTen/tt1121/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000001 -facility user
 0.1   0.0 85-01:23:15 /TimesTen/tt1121/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000000 -facility user
 0.0   0.0 85-01:45:28 /etc/init
 0.0   0.0 85-01:42:35 /usr/dt/bin/dtlogin -daemon
 0.0   0.0 85-01:42:30 dtlogin <:0>        -daemon
 0.0   0.0 85-01:42:30 /usr/lpp/X11/bin/X -x abx -x dbe -x GLX -D /usr/lib/X11//rgb -T -force :0 -auth /var/dt/A:0-6J7gqa
$get < Tab > ##另外一种用法,敲get后,加一个tab 还可以使用bash的补全,可以少敲命令,帮我们提示命令符
get_config  getconf     getdgrp     getlvodm    getopts     gettable    
get_tp      getdev      getea       getopt      getsystype  getty
$cat >> ~/.profile        #追加到用户启动配置中,用户登录后就可以直接使用了
source /tmp/_chao/_1311/ fun.sh
2、在进行sh脚本编写时,能直接调用此函数。
$ cat > t.sh
#!/usr/bin/bash
source /tmp/_chao/_1311/com.sh
get_tp
$ t.sh  ##运行t.sh,就可以直接调用函数:get_tp了。
 0.6   0.0       56:10 /home/test/oam/bin/oamAgent_alm 0 0 104
 0.1   0.0 85-01:54:55 /usr/sbin/syncd 60
 0.1   0.0 85-01:35:51 /TimesTen/tt1121/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000003 -facility user
 0.1   0.0 85-01:35:51 /TimesTen/tt1121/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000002 -facility user
 0.1   0.0 85-01:35:51 /TimesTen/tt1121/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000001 -facility user
 0.1   0.0 85-01:35:51 /TimesTen/tt1121/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000000 -facility user
 0.0   0.0 85-01:58:04 /etc/init
 0.0   0.0 85-01:55:11 /usr/dt/bin/dtlogin -daemon
 0.0   0.0 85-01:55:06 dtlogin <:0>        -daemon
 0.0   0.0 85-01:55:06 /usr/lpp/X11/bin/X -x abx -x dbe -x GLX -D /usr/lib/X11//rgb -T -force :0 -auth /var/dt/A:0-6J7gqa