随笔分类 -  linux shell

上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 78 下一页
摘要: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 阅读(195) 评论(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 阅读(34) 评论(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 阅读(42) 评论(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 阅读(153) 评论(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 阅读(62) 评论(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 阅读(43) 评论(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 阅读(65) 评论(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 阅读(83) 评论(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 阅读(850) 评论(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 阅读(225) 评论(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 阅读(28) 评论(0) 推荐(0)
摘要: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 阅读(69) 评论(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 阅读(338) 评论(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 阅读(91) 评论(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 阅读(97) 评论(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 阅读(79) 评论(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 阅读(476) 评论(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 阅读(152) 评论(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 阅读(42) 评论(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 阅读(530) 评论(0) 推荐(0)

上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 78 下一页