摘要: 一、数组创建 直接创建 m_array=(1 2 3 4) 赋值创建 m_array[0]=0 m_array[1]=1 m_array[2]=2 二、数组长度 echo "数组元素个数为: ${#m_array[*]}" echo "数组元素个数为: ${#m_array[@]}" 三、数组取值 阅读全文
posted @ 2021-07-17 20:48 繁忙的蜜蜂 阅读(42) 评论(0) 推荐(0) 编辑
摘要: 一、判断 语法 if condition1 then command1 elif condition1 then command2 else command3 fi 合并成一行 if [ condition1 ]; then command1; elif [ condition1 ]; then c 阅读全文
posted @ 2021-07-13 18:51 繁忙的蜜蜂 阅读(18) 评论(0) 推荐(0) 编辑
摘要: 一、整数 加减乘除 echo `expr 2 + 1` echo `expr 2 - 1` echo `expr 2 \* 1` echo `expr 2 / 1` 比较 -eq 等于,如:if [ "$a" -eq "$b" ] -ne 不等于,如:if [ "$a" -ne "$b" ] -gt 阅读全文
posted @ 2021-07-12 12:40 繁忙的蜜蜂 阅读(70) 评论(0) 推荐(0) 编辑
摘要: 处理过程: 依次对每一行进行处理,然后输出 命令形式 awk 参数 命令 文件 awk [-F|-f|-v] 'BEGIN{} //{command1; command2} END{}' file 参数列表 [-F | -f | -v] -F 指定分隔符 -f 指定使用脚本文件 -v 定义变量 DE 阅读全文
posted @ 2021-07-11 13:53 繁忙的蜜蜂 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 处理方式:逐行处理 处理类型:增删改查 文件demo: test.txt this is a test str. is 1 is 2 is 3 is 4 is 5 is 6 is 7 is 81234qwer -i 参数直接修改文件 插入选中行下一行文本, 开始标识字符 a\, 前置为选中行索引 s 阅读全文
posted @ 2021-07-11 12:50 繁忙的蜜蜂 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 长度 str='this is a test str.' expr length "${str}" 结果: "19" expr "${str}" : '.*' 结果: "19" 拼接 ?? 截取--索引 str='this is a test str.' expr substr "${str}" 2 阅读全文
posted @ 2021-07-11 12:01 繁忙的蜜蜂 阅读(86) 评论(0) 推荐(0) 编辑
摘要: 长度 str='this is a test str.' echo ${#str} 结果: "19" 拼接 a="123" b="abc" c="{|}" d1=${a}${b}${c} echo ${d1} 结果:"123abc{|}" d2=${a}"\n"${b}"\n"${c} echo $ 阅读全文
posted @ 2021-07-11 11:14 繁忙的蜜蜂 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 字符串赋值 shell中字符串赋值可以有如下几种方式 单引号 str1='str1.' 双引号 str2="str2." 无引号 str3=str3.反引号 str4=`ls` 单引号: 输出方式: 内容原样输出 demo: a='aa' b='$a' echo $b 结果: $a 假如想要将a的值 阅读全文
posted @ 2021-07-11 10:42 繁忙的蜜蜂 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 定时任务查看 crontab -l 写入定时配置 0 5 * * * /root/bin/test.sh 定时任务创建,修改 crontab -e 打开定时任务文件 定时任务文件删除 crontab -rcrontab -ir 删除前通知用户 配置参数含义 0 5 * * * /root/bin/t 阅读全文
posted @ 2021-07-10 21:47 繁忙的蜜蜂 阅读(190) 评论(0) 推荐(0) 编辑
摘要: alias 功能 设置指令别名 语法 alias[别名]=[指令名称] history 功能 查看历史执行命令 语法 history echo 功能 字符串输出 语法 echo "this is a test." cut 功能 字符串裁剪输出 语法 参数: -b :以字节为单位进行分割。这些字节位置 阅读全文
posted @ 2021-07-10 20:18 繁忙的蜜蜂 阅读(185) 评论(0) 推荐(0) 编辑