
shell 判断字符串是否包含另一个字符串
1.使用grep s1="abcdefg" s2="bcd" result=$(echo $s1 | grep "${s2}") if [[ "$result" != "" ]] then echo "$s1 include $s2" el...
1.使用grep s1="abcdefg" s2="bcd" result=$(echo $s1 | grep "${s2}") if [[ "$result" != "" ]] then echo "$s1 include $s2" el...
打印匹配行的前后5行 grep -5 ‘something’ file 打印匹配行的前后5行 grep -C 5 ‘something’ file 打印匹配行的后5行 grep -A 5 ‘something’ file...
1、创建测试数据 [root@linuxprobe test]# seq 30 > a.txt [root@linuxprobe test]# ls a.txt [root@linuxprobe test]# head a...
1、创建测试数据 [root@linuxprobe test]# seq 20 > a.txt [root@linuxprobe test]# ls a.txt [root@linuxprobe test]# head a.txt 1...
1、创建测试数据 [root@linuxprobe test3]# cat a.txt e i j s e f Y U D S D G 2、小写转换为大写 tr [root@linuxprobe test3]# tr [a-z...
1、创建测试数据 [root@linuxprobe test3]# cat a.txt wrwrt fdgsaf fsads gdfgde fsddd dffgdf sfdef sdfdsg 2、 [root@linuxpro...
1、创建测试数据 [root@linuxprobe test3]# echo {1..300} | xargs -n 15 > a.txt [root@linuxprobe test3]# cat a.txt 1 2 3 4 5 6 ...
1、创建测试数据 [root@linuxprobe test3]# cat a.txt w r t f s 4 6 6 a g g s d g r 4 d e w h s f g h 2、 [root@linuxprobe test3]# ...
shell命令从字符串中提取数字 echo “2020年7月21日” | tr -cd “[0-9]” 这样就可以提取出2020721
awk和sed之前看过,好久不用又忘记了,也没有总结,所以要学习还得再上网找资料,索性自己来总结一下。-print0和xargs之前一直在用,但是模模糊糊,一知半解,今天一并解决。 -print -print是find命令的一个参数,别的命...