随笔分类 - [09]Shell
Shell 脚本, 各种脚本
摘要:v='aaa_111' array=(JUMP_XCX != '' ]]; then # 可以判断空字符串 和 空数组 NEW_JUMP_XCX='' for v in ${JUMP_XCX[@]};do array=(
阅读全文
摘要:JUMP_XCX=('xxx_111' 'yyy_222' 'zzz_333') if [[ {JUMP_XCX[@]};do if [[ $NEW_JUMP_XC
阅读全文
摘要:# 判断是否启动了Redis,仅作为提醒 REDIS_PIDS=REDIS_PIDS" = "" ]; then Echo_Yellow "Redis is not run
阅读全文
摘要:本来1 >屏幕 (1指向屏幕) 执行>log后, 1 >log (1指向log) 执行2>&1后, 2 >1 (2指向1,而1指向log,因此2也指向了log) 通常放到后面!!! cnpm install >> $all_log_file 2>&1 # 将标准错误也输出到log中 , 2>&1 意
阅读全文
摘要:InstallWhileHostsExist="" Echo_Yellow "Do you want to continue install?" read -p "Default continue,Enter your choice [Y/n]: " InstallWhileHostsExist c
阅读全文
摘要:# sqlversion.php sqlversion_file={DB_HOST}';#g" $sqlversion_file s
阅读全文
摘要:# 判断是否安装了node if ! type node >/dev/null 2>&1; then echo 'node 未安装'; else echo 'node 已安装'; fi # 判断是否安装了npm if ! type npm >/dev/null 2>&1; then Echo_Red
阅读全文
摘要:Color_Text() { echo -e " \e[0;1\e[0m" } Echo_Red() { echo 1" "31") } Echo_Green() { echo 1" "32") } Echo_Yellow() {
阅读全文
摘要:# nginx 初始化,父脚本中的变量会自动传入引入的脚本中 . init/nginx.sh 子脚本内容 #!/bin/bash # 生成nginx配置 # cur_dir=(dirname $(pwd)) # input_name=demo # input_do
阅读全文
摘要:1 dash中 echo 'hello\nworld' 将会输出 hello world 2 bash中 echo 'hello\nworld' 将会输出 hello\nworld 一般情况下 /bin/sh 被软链到 /bin/dash,偶尔也会遇到有人把 /bin/sh 软链到 /bin/bas
阅读全文
摘要:当前目录 cur_dir=(dirname $(pwd))
阅读全文
摘要:尾部 # 将域名写入hosts文件 echo "127.0.0.1 input_domain" /etc/hosts
阅读全文
摘要:# 判断hosts中有域名 if cat '/etc/hosts' | grep "input_domain已存在" domain_flag='' continue fi
阅读全文
摘要:正则表达式匹配域名 ^(http(s)?:\/\/)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:[0-9]{1,5})?$ 在shell中使用 read -p "请输入域名: " input_domain ech
阅读全文
摘要:1.清理超过一定大小的日志 2.清理超过一定时间的日志 这里最最核心的就是,查询出他们,然后进行循环操作。
阅读全文
摘要:增加可读性 函数 效果 加参数 执行效果 全局变量 执行效果
阅读全文
摘要:运行结果 结合select做选择菜单。 执行的时候,必须用bash来执行。
阅读全文