随笔分类 - linux shell
摘要:1、测试数据 root@PC1:/home/test2# cat test.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 28 29 30 31 32 33 34 35 36
阅读全文
摘要:1、 root@PC1:/home/test2# ls test1.txt test2.txt root@PC1:/home/test2# cat test1.txt 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 root@P
阅读全文
摘要:1、awk实现 root@PC1:/home/test2# ls test.txt root@PC1:/home/test2# cat test.txt ## 测试数据 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 root@
阅读全文
摘要:1、问题,下载压缩文件后,不能显示压缩文件的颜色(红色),执行source ./bashrc后系统可以显示 问题如下,因此推测是系统启动时没有自动执行source ./bashrc 2、解决方法,在~/.bash_profile增加如下语句: if [ -f ~/.bashrc ]; then .
阅读全文
摘要:1、find可以实现对指定文件大小的查找 root@PC1:/home/test2# ls b.ped outcome.map outcome.ped root@PC1:/home/test2# ll -h total 1.4G -rw-r--r-- 1 root root 1.3G 12月 22
阅读全文
摘要:1、 root@PC1:/home/test2# ls b.ped outcome.map outcome.ped xx root@PC1:/home/test2# du -ah ## 显示每一个文件的大小 4.0K ./xx 1.3M ./outcome.map 1.3G ./b.ped 158M
阅读全文
摘要:1、croc安装 方法1: curl https://getcroc.schollz.com | bash 方法2(ubuntu): gdebi croc_8.3.2_Linux-64bit.deb ## (需要提前下载好安装包) https://github.com/schollz/croc/re
阅读全文
摘要:1、测试主机PC1、PC2 root@PC1:/home/test2# ls root@PC1:/home/test2# hostname PC1 root@PC1:/home/test2# ifconfig | head -n 3 ens32: flags=4163<UP,BROADCAST,RU
阅读全文
摘要:1、测试数据 root@PC1:/home/test# ls outcome.ped root@PC1:/home/test# cat outcome.ped ## 测试数据, 将每隔一个空格的两列并排为一列 G G C C G G G G G A A A G G G C G G G C G G G
阅读全文
摘要:1、删除test.txt末尾的单个或者多个空格或者制表符 root@PC1:/home/test# ls test.txt root@PC1:/home/test# cat test.txt ## 测试数据 2 3 4 a 3 d d w e z v e z c g z v b root@PC1:/
阅读全文
摘要:1、测试数据,依据列数筛选数据 root@PC1:/home/test# ls test.txt root@PC1:/home/test# cat test.txt ## 测试数据 2 3 4 3 d a 3 d d w e f z v e z c g k e q z v b d root@PC1:
阅读全文
摘要:1、问题 ubuntu中解压rar文件, 如下: root@PC1:/home/test2# ls test.rar root@PC1:/home/test2# unrar e test.rar -bash: /usr/bin/unrar: No such file or directory 2、解
阅读全文
摘要:sort命令 -g选项忽略字母 1、测试数据 root@PC1:/home/test# ls a.txt root@PC1:/home/test# cat a.txt name gender score ddd 2 8 aa 1 87 ff 2 3 ss 1 23 root@PC1:/home/te
阅读全文
摘要:1、测试数据 root@PC1:/home/test/test# ls test.txt root@PC1:/home/test/test# cat test.txt ## 实现将每行最后一个e替换为xxx e r e y e u e e e g e 3 h r 1 3 e g e y e e s
阅读全文
摘要:1、创建测试数据 root@PC1:/home/test/test# seq -f %02g 40 | awk '{if(NR % 4 == 0) {print $0} else {printf("%s ", $0)}}' ## 利用seq命令产生连续数字,然后利用awk分配行 01 02 03 0
阅读全文
摘要:linux shell中统计文本中指定单词出现的次数 1、测试数据, 统计 a.txt中e出现的总次数 root@PC1:/home/test/test# cat a.txt e r e y e u e e e g e 3 h r 1 3 e g e y e e s e e e e e 2、awk实
阅读全文
摘要:1、测试数据如下, 实现将每行的第3个e及其以后的e替换为g root@PC1:/home/test/test# cat a.txt e r e y e u e e e g e 3 h r 1 3 e g e y e e s e e e e e 3、 root@PC1:/home/test/test
阅读全文
摘要:1、最后一行末尾追加字符 root@ubuntu01:/home/test2# cat num.txt 1 1 1 2 root@ubuntu01:/home/test2# sed '$ s/$/ final/' num.txt ## 使用sed实现, 第一个$限制最后一行, 第二个$指出替换的位置
阅读全文
摘要:1、将1至4各重复3次, shell双循环实现 root@ubuntu01:/home/test2# ls root@ubuntu01:/home/test2# for i in `seq 4`; do for j in `seq 3`; do echo $i >> num.txt; done; d
阅读全文
摘要:1、测试数据 root@ubuntu01:/home/test2# cat test.txt ## 实现将每一行按照第二行数字指定的行数重复 1 3 e3rt idf 2 2 32 ffj 3 5 cc kkk 4 4 wf 34 2、while + for双循环实现 root@ubuntu01:/
阅读全文