随笔分类 - linux shell
摘要:001、 +号的作用是匹配前面字符1次或连续任意多次 root@PC1:/home/test/test# ls a.txt root@PC1:/home/test/test# cat a.txt aaaabxa xxxxbxa root@PC1:/home/test/test# sed 's/a+/
阅读全文
摘要:1、测试数据 root@PC1:/home/test/test# ls uma.txt root@PC1:/home/test/test# cat -A uma.txt 0^M^IAAACGCTGTAGCCA-1$ 0^M^IAAACTTGATCCAGA-1$ 1^M^IAAAGAGACGAGATA
阅读全文
摘要:1、 root@PC1:/home/test4# ls a.txt b.txt root@PC1:/home/test4# cat a.txt a a b b c d e root@PC1:/home/test4# cat b.txt c d e f f g root@PC1:/home/test4
阅读全文
摘要:1、测试数据 root@PC1:/home/test4# ls a.txt b.txt root@PC1:/home/test4# cat a.txt a b c d e root@PC1:/home/test4# cat b.txt c d d xef e f g 2、grep -f选项的作用表示
阅读全文
摘要:分类1:当两个文件没有重复项时。 1、测试数据 root@PC1:/home/test4# ls a.txt b.txt root@PC1:/home/test4# cat a.txt ## 测试数据 a b c d e root@PC1:/home/test4# cat b.txt c d e f
阅读全文
摘要:1、 root@PC1:/home/test2# ls test.sh root@PC1:/home/test2# cat test.sh ## 脚本 #!/bin/bash ANSWER=$(expr $RANDOM % 100) TIMES=0 echo "the range is 0-100,
阅读全文
摘要:001、 root@PC1:/home/test2# ls root@PC1:/home/test2# a=abd root@PC1:/home/test2# echo $a abd root@PC1:/home/test2# [ $a =~ ^a ] && echo yes ## 单个[]不支持匹
阅读全文
摘要:1、 root@PC1:/home/test2# ls test.sh root@PC1:/home/test2# cat test.sh ## script #!/bin/bash SUM=0 MIN=100 MAX=0 COUNT=0 while [ $COUNT -lt 5 ] do read
阅读全文
摘要:[[:alnum:]] = [a-zA-Z0-9] root@PC1:/home/test/test# ls a.txt root@PC1:/home/test/test# cat a.txt GMM 201 0 0 0 GMM 202 0 0 0 GMM 203 0 0 0 root@PC1:/h
阅读全文
摘要:001、 root@PC1:/home/test2# ls a.txt root@PC1:/home/test2# cat a.txt hello world root@PC1:/home/test2# sed 's/\(hello\) \(world\)/\2 \1/' a.txt ## 第一个小
阅读全文
摘要:1、系统 [root@PC1 network-scripts]# hostnamectl Static hostname: PC1 Icon name: computer-vm Chassis: vm Machine ID: 7d8c7dacd42740ff9603a3e8bbf222da Boot
阅读全文
摘要:1、 root@PC1:/home/test# ls a.txt root@PC1:/home/test# cat a.txt i aaaadff f aaewrg k aaarbcd j aaaaavvvv i aaaaaaaaere root@PC1:/home/test# grep -E "a
阅读全文
摘要:1、sort -u实现 root@PC1:/home/test# ls a.txt root@PC1:/home/test# cat a.txt a b c x y z a b c m n o m n o root@PC1:/home/test# sort -u a.txt ## sort -u删除
阅读全文
摘要:1、 root@PC1:/home/test# ls a.txt root@PC1:/home/test# cat a.txt ## 测试数据 d xaa c xaaa d xaaaa e xaaaaa f xaaaaaa d dff gfgfgf e dfgdg gfdgedr d dfef fc
阅读全文
摘要:1、 root@PC1:/home/test# ls a.txt root@PC1:/home/test# cat a.txt ## 测试数据 d aab c aaab d aaaax e aaaaax f aaaaaax root@PC1:/home/test# grep -E "a{2}" a.
阅读全文
摘要:1、 root@liujiaxinpc1:/home/test# echo $a 100 root@liujiaxinpc1:/home/test# echo $b root@liujiaxinpc1:/home/test# [ $a ] ## 变量有赋值, 返回真 root@liujiaxinpc
阅读全文
摘要:-n: 当字符串不为0是为真; 字符串为0是为假。 n表示non-zero 示例: root@liujiaxinpc1:/home/test# a=100 root@liujiaxinpc1:/home/test# echo $a 100 root@liujiaxinpc1:/home/test#
阅读全文
摘要:原文:https://blog.csdn.net/coolfishbone_joey/article/details/119956378 echo 显示内容颜色,需要使用 -e 参数 -e :打开反斜杠转义 (默认不打开) ,可以转义 “\n, \t” 等 -n:在最后不自动换行 str="kimb
阅读全文
摘要:1、举例1: root@PC1:/home/test# ls test.sh root@PC1:/home/test# cat test.sh #!/bin/bash read -p "please input a character: " KEY case $KEY in ## 利用变量KEY进行
阅读全文
摘要:1、统计频次 [root@localhost test]# ls a.txt [root@localhost test]# cat a.txt a a b a b a b b b b [root@localhost test]# awk '{array[$1]++} END {for(i in ar
阅读全文