1.系统自建了函数库,可以在脚本中引用

  /etc/init.d/functions

2.自建函数库

  使用 source 函数脚本文件 “导入”函数

3.

  vim /etc/init.d/functions   #函数脚本

  

#此函数为打印一个确定按钮
echo_success(){
    ["$BOOTUP" = "color" ] && $MOVE_TO_COL
    echo -n "["
    ["$BOOTUP" = "color"] && $SETCOLOR_SUCCESS
    echo -n $" OK "
    ["$BOOTUP" = "color"] && $SETCOLOR_NORMAL
    echo -n "]"
    echo -ne "\r"
    return 0
 }

  source /etc/init.d/functions   #使用functions脚本

  echo_success   #使用echo_success函数

  

4.

  vim /etc/profile     #环境变量脚本

  

pathmunge(){
    case ":${PATH}:" in
        *:"$1":*)
               ;;
         *)
              if [] ;then
                    PATH=$PATH:$1
              else
                    PATH=$1:$PATH
              fi

    esac
}                

 

5.

# .bashrc
    
#User specific aliases and functons

alias rm='rm -i'    #alias 别名的意思
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [-f /etc/bashrc];then
        . /etc/bashrc         #如果存在/etc/bashr则运行/etc/bashr
fi

 

6.

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ];then
      . ~/bashrc
fi

#User specific environment and startup programs
PATH=$PATH:$HOME/bin

export PATH

 

7.

 

posted on 2020-01-05 17:09  大话人生  阅读(440)  评论(0编辑  收藏  举报