随笔分类 - linux shell
摘要:001、 [root@pc1 test1]# ls ## 三个测试文件 a.txt b.txt testfile [root@pc1 test1]# ll -h total 4.0K lrwxrwxrwx. 1 root root 20 Sep 16 12:03 a.txt -> /home/tes
阅读全文
摘要:001、 [root@pc1 test1]# ls ## 测试文件 a.txt a.TXT c.csv c.tXt d.txt e.Txt f.csv k.map [root@pc1 test1]# find ./ -name "*.txt" ## 显示相对路径 ./a.txt ./d.txt [r
阅读全文
摘要:001、 -iname选项 实现忽略大小写查找 [root@pc1 test1]# ls ## 测试文件 a.txt a.TXT c.csv c.tXt d.txt e.Txt f.csv k.map [root@pc1 test1]# find ./ -name "*.txt" ## 一般查找 .
阅读全文
摘要:001、 针对普通用户 [liujiaxin01@pc1 ~]$ ls test01 [liujiaxin01@pc1 ~]$ pwd ## 普通用户家目录 /home/liujiaxin01 [liujiaxin01@pc1 ~]$ tree ## 重要文件所在目录 . └── test01 └─
阅读全文
摘要:001、方法1 [root@pc1 test01]# ls a.txt b.txt [root@pc1 test01]# cat a.txt 1 2 3 4 5 6 [root@pc1 test01]# cat b.txt a b c d e f [root@pc1 test01]# paste -
阅读全文
摘要:001、 提取两个文件中指定列相同的行 [root@pc1 test01]# ls file1 file2 [root@pc1 test01]# cat file1 a rs1 b rs2 c rs4 [root@pc1 test01]# cat file2 a 0.170721 -1.82031
阅读全文
摘要:001、 awk [root@pc1 test02]# ls a.txt [root@pc1 test02]# cat a.txt a ii b kk a jj c yy b 77 e tt [root@pc1 test02]# awk '!ay[$1]++' a.txt a ii b kk c y
阅读全文
摘要:001、 [root@pc1 test02]# ls a.txt [root@pc1 test02]# 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 test02]# c
阅读全文
摘要:001、 [root@pc1 test02]# ls a.sh b.sh [root@pc1 test02]# cat a.sh ## 测试程序1 #!/bin/bash str1="ab_cd_ef" tmp1=$(echo $str1 | sed 's/_/\n/g') echo $tmp1 [
阅读全文
摘要:001、 方法1 [root@pc1 test01]# ls a.txt test.sh [root@pc1 test01]# cat a.txt ## 测试数据, 依据最后一列展开为多行 chrY 2657879 2658063 CTCF 652 GM19239 chrY 2664424 2664
阅读全文
摘要:001、 [root@pc1 test02]# ls a.txt [root@pc1 test02]# cat a.txt ## 测试数据 01 02 03 04 05 06 07 08 09 10 ## 获取数组的长度 [root@pc1 test02]# awk 'BEGIN{ay["a"] =
阅读全文
摘要:001、方法1 [root@pc1 test03]# ls a.txt [root@pc1 test03]# cat a.txt ## 测试数据 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
阅读全文
摘要:001、 [root@pc1 test03]# ls a.txt [root@pc1 test03]# cat a.txt ## 测试数据 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
阅读全文
摘要:001、find >>> str1 = "xyabmnabkj" ## 测试字符串 >>> for i in enumerate(str1): ... print(i) ## 列出每个字符的索引 ... (0, 'x') (1, 'y') (2, 'a') (3, 'b') (4, 'm') (5,
阅读全文
摘要:001、 [root@pc1 test01]# ls ## 测试文件 a.txt test01 test02 test03 [root@pc1 test01]# find ./ -type f -exec ls -l {} \; ## 列出文件大小 -rw-r--r--. 1 root root 2
阅读全文
摘要:001、 [root@pc1 test01]# cat a.txt A:10 B:5 C:12 [root@pc1 test01]# cat b.txt 100 A 50 B 88 K 99 Y 42 C [root@pc1 test01]# awk '{if(NR == FNR) {ay[$1]
阅读全文
摘要:001、 正确做法 [root@pc1 test01]# ls a.txt b.txt [root@pc1 test01]# cat a.txt A:10 B:5 C:12 [root@pc1 test01]# cat b.txt 100 A 50 B 42 C [root@pc1 test01]#
阅读全文
摘要:001、 方法1 [root@pc1 test01]# ls a.txt b.txt [root@pc1 test01]# cat a.txt A:10 B:5 C:12 [root@pc1 test01]# cat b.txt 100 A 50 B 42 C [root@pc1 test01]#
阅读全文
摘要:001、 -F 指定 [root@pc1 test01]# ls a.txt [root@pc1 test01]# cat a.txt a:b:c 3:8:k f:6:3 [root@pc1 test01]# awk -F ":" '{print $1}' a.txt a 3 f 002、-v FS
阅读全文
摘要:001、去重复保持原来的顺序 [root@pc1 test01]# ls a.txt [root@pc1 test01]# cat a.txt ## 测试数据 1 2 5 5 3 3 7 7 4 [root@pc1 test01]# awk 'ay[$0]++' a.txt ## 输出重复项,且保持
阅读全文

浙公网安备 33010602011771号