摘要: 001、 -c: complement:表示取补集; -d:delete:表示删除 [root@pc1 test1]# echo "ab,123.cd-458fqq" | tr -dc [[:digit:]] | sed 's/$/\n/' ## 删除所有数字的补集,则剩下数字 123458 [ro 阅读全文
posted @ 2024-02-19 17:37 小鲨鱼2018 阅读(31) 评论(0) 推荐(0) 编辑
摘要: 001、$RANDOM (0~32767的随机数) a、 [root@pc1 test1]# echo $RANDOM ## 直接输出 31128 [root@pc1 test1]# echo $RANDOM 2539 [root@pc1 test1]# echo $RANDOM 23307 b、限 阅读全文
posted @ 2024-02-19 17:16 小鲨鱼2018 阅读(5) 评论(0) 推荐(0) 编辑
摘要: 001、方式1 [root@pc1 test1]# awk 'BEGIN{print 10 + 5}' 15 [root@pc1 test1]# awk 'BEGIN{print 10 / 5}' 2 002、方式2 [root@pc1 test1]# echo | awk '{print 10 + 阅读全文
posted @ 2024-02-19 16:56 小鲨鱼2018 阅读(45) 评论(0) 推荐(0) 编辑
摘要: 001、 [root@pc1 test1]# ls a.txt [root@pc1 test1]# cat a.txt ## 测试文本 33 ff su ii aa kk ff dd sU jj kk ff aa Su ee aa SU kk ff xx ad sk uu ff [root@pc1 阅读全文
posted @ 2024-02-19 15:34 小鲨鱼2018 阅读(29) 评论(0) 推荐(0) 编辑
摘要: 001、 [root@pc1 test1]# ls a.txt [root@pc1 test1]# cat a.txt ## 测试文本 dd ff iiabcjjj ff aa qq aaabcabcabckk aa abc ff uuu aa abcabcabcabcjj kk uu [root@ 阅读全文
posted @ 2024-02-19 15:29 小鲨鱼2018 阅读(47) 评论(0) 推荐(0) 编辑
摘要: 0:找到匹配模式 1:未找到匹配模式 2:指定的输入文件不对 001、 [root@pc1 test1]# ls a.txt [root@pc1 test1]# cat a.txt ## 测试文本 aa bb cc 11 aa 33 33 dd bb [root@pc1 test1]# grep " 阅读全文
posted @ 2024-02-19 15:05 小鲨鱼2018 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 001、while循环:条件满足一直执行 [root@pc1 test1]# i=1 ## 条件满足,一直执行 [root@pc1 test1]# while [[ $i -le 3 ]]; do echo $i; i=$((i+1)); done 1 2 3 002、until循环;条件不满足一直 阅读全文
posted @ 2024-02-19 12:05 小鲨鱼2018 阅读(27) 评论(0) 推荐(0) 编辑
摘要: 001、for循环:for循环的终止条件在for语句后面已经提前已知 [root@pc1 test1]# for ((i = 1; i <= 3; i++)); do echo $i; done ## 终止条件i <= 3; i的变化规律;提前已知 1 2 3 002、while循环; while循 阅读全文
posted @ 2024-02-19 11:59 小鲨鱼2018 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 001、-a: 后跟一个变量,该变量会被认为是个数组,然后给其赋值,默认是以空格为分割符。 [root@pc1 test1]# read -a ay1 ## -a数据读入数组变量 aa bb cc 100 800 [root@pc1 test1]# echo $ay1 aa [root@pc1 te 阅读全文
posted @ 2024-02-19 11:23 小鲨鱼2018 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 001、let [root@pc1 test1]# a=1 [root@pc1 test1]# echo $a 1 [root@pc1 test1]# let a=$a+50 ## 数值变量递加 [root@pc1 test1]# echo $a 51 002、使用括号(()) [root@pc1 阅读全文
posted @ 2024-02-19 10:26 小鲨鱼2018 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 通常更推荐使用双方引号。 001、双方引号可以避免变量的单词分割 [root@pc1 test1]# str1="aa bb" ## 测试字符串 [root@pc1 test1]# if [[ $str1 == "aa bb" ]]; then echo "yes"; fi ## 双边引号不用担心变 阅读全文
posted @ 2024-02-19 09:17 小鲨鱼2018 阅读(7) 评论(0) 推荐(0) 编辑
摘要: 内部字符单分隔符(Internal Field Separator,IFS) 是一个系统环境变量; 无法使用echo $IFS进行查看 001、查看IFS [root@pc1 test1]# set | grep "^IFS" ## 系统默认的IFS IFS=$' \t\n' [root@pc1 t 阅读全文
posted @ 2024-02-19 09:12 小鲨鱼2018 阅读(11) 评论(0) 推荐(0) 编辑