摘要: 001、方法1 双文件 [root@PC1 test1]# ls a.txt cols.list [root@PC1 test1]# cat cols.list ## 列 1 3 5 8 [root@PC1 test1]# cat a.txt ## 测试文件 001 002 003 004 005 阅读全文
posted @ 2024-02-10 23:32 小鲨鱼2018 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 001、直接合并 [root@PC1 test1]# str1=aa [root@PC1 test1]# str2=bb ## 测试字符串 [root@PC1 test1]# str3=$str1$str2 ## 直接合并 [root@PC1 test1]# echo $str3 ## 输出合并结果 阅读全文
posted @ 2024-02-10 23:09 小鲨鱼2018 阅读(34) 评论(0) 推荐(0) 编辑
摘要: 001、字符串转换为shell数组 [root@PC1 test1]# str1="aa bb 100 200 500" ## 生成测试字符串 [root@PC1 test1]# echo $str1 aa bb 100 200 500 [root@PC1 test1]# ay1=($str1) # 阅读全文
posted @ 2024-02-10 22:43 小鲨鱼2018 阅读(253) 评论(0) 推荐(0) 编辑
摘要: 001、字符串变量传入awk,然后转换为数组 [root@PC1 test1]# str1="1 3 7 8" ## 测试字符串 [root@PC1 test1]# awk -v a="$str1" 'BEGIN{split(a, ay1, " "); print length(ay1)}' ## 阅读全文
posted @ 2024-02-10 22:27 小鲨鱼2018 阅读(14) 评论(0) 推荐(0) 编辑
摘要: 001、先看整体结构 [root@PC1 test1]# ls ## 测试文件及目录 a.txt test001 test002 test003 [root@PC1 test1]# tree -h ## 查看结构和各个文件的大小 . ├── [ 59] a.txt ├── [ 30] test001 阅读全文
posted @ 2024-02-10 20:08 小鲨鱼2018 阅读(34) 评论(0) 推荐(0) 编辑
摘要: 001、 -w选项锁定 [root@PC1 test1]# ls a.txt [root@PC1 test1]# cat a.txt ## 测试文本 3432 dsab45cdf 887 abc 33333 77777 sdf fffabc 8888 ddd kk22,kk33k wwww sss 阅读全文
posted @ 2024-02-10 19:00 小鲨鱼2018 阅读(22) 评论(0) 推荐(0) 编辑
摘要: \w ## 匹配文字和数字字符,也就是[A-Za-z0-9], \W ## \w的反置形式,匹配一个或多个非单词字符,如点号句号等。 01、 [root@PC1 test1]# ls a.txt [root@PC1 test1]# cat a.txt ## 测试文本 3432 dsab45cdf 8 阅读全文
posted @ 2024-02-10 19:00 小鲨鱼2018 阅读(84) 评论(0) 推荐(0) 编辑
摘要: 001、 -a: 显示所有目录及文件的大小 [root@PC1 test1]# ls ## 测试文件及目录 a.txt test001 test002 test003 [root@PC1 test1]# du -ah ## 输出所有文件及目录的大小 4.0K ./a.txt 1000M ./test 阅读全文
posted @ 2024-02-10 17:04 小鲨鱼2018 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 001、 [root@PC1 test]# ls a.txt [root@PC1 test]# cat a.txt ## 测试文件 yy 33 gg ss ff 11 zz mm dd 88 44 cc [root@PC1 test]# awk 'NF' a.txt ## 每行重复1次 yy 33 阅读全文
posted @ 2024-02-10 12:07 小鲨鱼2018 阅读(25) 评论(0) 推荐(0) 编辑
摘要: 001、 [root@PC1 test]# ls a.txt [root@PC1 test]# cat a.txt ## 测试数据 444 777 222 999 eee 333 222 666 111 ggg sss fff zzz mmm nnn rrr ttt hhh [root@PC1 te 阅读全文
posted @ 2024-02-10 10:49 小鲨鱼2018 阅读(12) 评论(0) 推荐(0) 编辑