首页 > 代码库 > 可以借鉴的脚本函数

可以借鉴的脚本函数


 

输出颜色

Color_Text(){echo -e " \e[0;$2m$1\e[0m"}Echo_Red(){echo $(Color_Text "$1" "31")}Echo_Green(){echo $(Color_Text "$1" "32")}Echo_Yellow(){echo $(Color_Text "$1" "33")}Echo_Blue(){echo $(Color_Text "$1" "34")}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

stty命令,调用

Press_Install(){echo ""Echo_Green "Press any key to install...or Press Ctrl+c to cancel"OLDCONFIG=`stty -g`stty -icanon -echo min 1 time 0dd count=1 2>/dev/nullstty ${OLDCONFIG}. include/version.shKill_PM}


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

从网上下载资源

Download_Mirror=http://soft.vpser.netAutoconf_Ver=autoconf-2.13Download_Files ${Download_Mirror}/lib/autoconf/${Autoconf_Ver}.tar.gz ${Autoconf_Ver}.tar.gzDownload_Files(){local URL=$1local FileName=$2if [ -s "${FileName}" ]; thenecho "${FileName} [found]"elseecho "Notice: ${FileName} not found!!!download now..." #-c, --continue 接着下载没下载完的文件#--progress=TYPE 设定进程条标记wget -c --progress=bar:force ${URL}fi}


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

解压缩并且进入目录

Tar_Cd(){local FileName=$1local DirName=$2cd ${cur_dir}/src[[ -d "${DirName}" ]] && rm -rf ${DirName}echo "Uncompress ${FileName}..."tar zxf ${FileName}echo "cd ${DirName}..."cd ${DirName}}

可以借鉴的脚本函数