摘要: 001、ARGC :命令行参数数组ARGV中元素的个数(c:count; v:variable) [root@PC1 test1]# ls a.txt b.txt [root@PC1 test1]# awk '{print ARGC}' a.txt ## ARGC:表示命令行参数数组ARGV中元素的 阅读全文
posted @ 2024-02-20 23:10 小鲨鱼2018 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 001、-I [root@PC1 test1]# ls 1.txt 2.txt 3.txt dir01 [root@PC1 test1]# find *.txt | xargs -I {} mv {} dir01/ ## -I 将前边的变量存储至{},便于后续处理 [root@PC1 test1]# 阅读全文
posted @ 2024-02-20 18:25 小鲨鱼2018 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 001、字符串首字母转换为大写;以及全部转换为大写 [root@PC1 test1]# str1="abcde" ## 测试字符串 [root@PC1 test1]# echo ${str1^} ## 首字母转换为大写 Abcde [root@PC1 test1]# echo ${str1^^} # 阅读全文
posted @ 2024-02-20 18:22 小鲨鱼2018 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 001、 [root@pc1 tmp]# echo {1..30}|xargs printf "%02d %03d\n" 01 002 ## xargs 标准化输出参数 03 004 05 006 07 008 09 010 11 012 13 014 15 016 17 018 19 020 21 阅读全文
posted @ 2024-02-20 18:18 小鲨鱼2018 阅读(11) 评论(0) 推荐(0) 编辑
摘要: linux 中 条件判断中 -r; -n选项; 001、-r选项用于判断文件是否拥有读的权限;测试如下: a、root用户 [root@pc1 test1]# ls a.sh [root@pc1 test1]# ll -h ## 文件a.sh没有任何权限 total 4.0K . 1 root ro 阅读全文
posted @ 2024-02-20 16:26 小鲨鱼2018 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 001、 [root@pc1 test1]# ls a.txt [root@pc1 test1]# cat a.txt ## 测试文件 abcdaaa kaass aa [root@pc1 test1]# sed 's/a/Q/g' a.txt ##加g; 默认是全部替换 QbcdQQQ kQQss 阅读全文
posted @ 2024-02-20 15:34 小鲨鱼2018 阅读(25) 评论(0) 推荐(0) 编辑
摘要: 4种; 01、bash a.sh 02、sh a.sh 03、. a.sh 04、source 前两种会重开shell终端; 后两种是本shell; 测试如下: 001、测试前两种方法;不影响当前路径 [root@pc1 test1]# ls a.sh [root@pc1 test1]# pwd # 阅读全文
posted @ 2024-02-20 15:14 小鲨鱼2018 阅读(12) 评论(0) 推荐(0) 编辑
摘要: 001、问题 shell终端下,双引号内输出!报错 [root@pc1 test1]# echo "hello world!" -bash: !": event not found 002、问题原因 终端中! 表示执行历史命令。 003、解决方法 a、使用单引号 [root@pc1 test1]# 阅读全文
posted @ 2024-02-20 14:48 小鲨鱼2018 阅读(7) 评论(0) 推荐(0) 编辑
摘要: 001、 [root@pc1 test1]# ls a.txt [root@pc1 test1]# cat a.txt ## 测试文本 aa bb cc kk ee ss ff uu zz vv ee ww ## sed预存储抽取文件的第一列 [root@pc1 test1]# sed -r 's/ 阅读全文
posted @ 2024-02-20 12:25 小鲨鱼2018 阅读(22) 评论(0) 推荐(0) 编辑
摘要: -r:其中一项作用是保证字符为其本身字符; 没有-r字符具有正则意义; 如下例子: 001、 一下命令用于sed删除开头的空格 [root@pc1 test1]# ls a.txt [root@pc1 test1]# cat a.txt ## 测试文本 01 02 03 04 05 06 07 08 阅读全文
posted @ 2024-02-20 11:38 小鲨鱼2018 阅读(367) 评论(0) 推荐(0) 编辑
摘要: 001、输出偶数行 [root@pc1 test1]# ls a.txt [root@pc1 test1]# cat a.txt ## 测试文本 01 01 02 02 03 03 04 04 05 05 06 06 07 07 08 08 09 09 10 10 [root@pc1 test1]# 阅读全文
posted @ 2024-02-20 11:01 小鲨鱼2018 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 001、整体重复 a、 [root@pc1 test1]# ls a.txt [root@pc1 test1]# cat a.txt ## 测试文本 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 [root@pc1 test1 阅读全文
posted @ 2024-02-20 10:51 小鲨鱼2018 阅读(5) 评论(0) 推荐(0) 编辑