随笔分类 -  linux shell

摘要:1、id命令用于反馈用于ID,所属组ID,(所属组名 ?) 使用root测试结果: [root@linuxprobe home]# whoami ## root用户 root [root@linuxprobe home]# echo $USER root [root@linuxprobe home] 阅读全文
posted @ 2020-10-12 21:50 小鲨鱼2018 阅读(1268) 评论(0) 推荐(0)
摘要:1、基本结构 #!/bin/bash ## 声明脚本解释器 for 变量 in 可迭代对象 do 循环体 done 2、简单实例 [root@linuxprobe test3]# for i in 1 10 100 500;do echo $i;done ## 可以直接在命令行中使用,变量前需加 $ 阅读全文
posted @ 2020-10-12 21:39 小鲨鱼2018 阅读(856) 评论(0) 推荐(0)
摘要:1、创建测试数据 [root@linuxprobe test3]# cat a.txt e i j s e f Y U D S D G 2、小写转换为大写 tr [root@linuxprobe test3]# tr [a-z] [A-Z] < a.txt ## 所有小写字符转换为大写 E I J 阅读全文
posted @ 2020-10-11 23:27 小鲨鱼2018 阅读(3316) 评论(0) 推荐(1)
摘要:1、创建测试数据 [root@linuxprobe test3]# cat a.txt wrwrt fdgsaf fsads gdfgde fsddd dffgdf sfdef sdfdsg 2、 [root@linuxprobe test3]# sed 's/.//' a.txt ##删除开头一个 阅读全文
posted @ 2020-10-11 22:28 小鲨鱼2018 阅读(3902) 评论(0) 推荐(0)
摘要:1、创建测试数据 [root@linuxprobe test3]# cat a.txt w r t f s 4 6 6 a g g s d g r 4 d e w h s f g h 2、 [root@linuxprobe test3]# grep -E '^w|^a|h$' a.txt ## 提取 阅读全文
posted @ 2020-10-11 21:45 小鲨鱼2018 阅读(1490) 评论(0) 推荐(0)
摘要:1、创建测试数据 [root@linuxprobe test3]# echo {1..300} | xargs -n 15 > a.txt [root@linuxprobe test3]# cat a.txt 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 阅读全文
posted @ 2020-10-11 21:35 小鲨鱼2018 阅读(10426) 评论(0) 推荐(0)
摘要:1、运行python程序遇到下面问题,python版本3.6.8 ModuleNotFoundError: No module named 'scipy' 2、 pip3 install scipy 阅读全文
posted @ 2020-10-11 10:21 小鲨鱼2018 阅读(8222) 评论(0) 推荐(0)
摘要:1、运行python程序,遇到下面报错,python版本3.6.8 import numpy as np ModuleNotFoundError: No module named 'numpy' 2、执行如下命令 pip3 install numpy 阅读全文
posted @ 2020-10-10 23:58 小鲨鱼2018 阅读(7033) 评论(0) 推荐(0)
摘要:1、创建测试数据 [root@linuxprobe test]# cat a.txt ## 随机创建测试数据 fr dfg rte er hdf fgh dg fgd rtw er ewr scf yt ret tgr 2、简单用法 [root@linuxprobe test]# awk '$1 ~ 阅读全文
posted @ 2020-10-09 13:00 小鲨鱼2018 阅读(2737) 评论(0) 推荐(0)
摘要:1、创建测试数据 利用awk进行合并(1) [root@linuxprobe test2]# seq -w 30 | xargs -n 2 | sed = | sed 'N;s/\n/> /' > a.txt ##创建测试数据 [root@linuxprobe test2]# cat a.txt 1 阅读全文
posted @ 2020-10-06 15:34 小鲨鱼2018 阅读(1024) 评论(0) 推荐(0)
摘要:1、利用xargs命令将多列数据转化为一列数据 [root@linuxprobe test2]# echo "1 2 3 4 5 6" > a.txt [root@linuxprobe test2]# cat a.txt 1 2 3 4 5 6 [root@linuxprobe test2]# ca 阅读全文
posted @ 2020-10-06 14:57 小鲨鱼2018 阅读(2170) 评论(0) 推荐(0)
摘要:1、利用xargs进行行列转换 [root@linuxprobe test2]# seq 512345[root@linuxprobe test2]# seq 5 | xargs ## xargs 默认转化为1行1 2 3 4 5[root@linuxprobe test2]# seq 5000 | 阅读全文
posted @ 2020-10-06 13:54 小鲨鱼2018 阅读(2566) 评论(0) 推荐(0)
摘要:1、基本用法,直接运行date 显示系统当前时间 [root@linuxprobe test]# date Mon Oct 5 20:03:00 CST 2020 2、以特定格式输出,如“年-月-日 时:分:秒” [root@linuxprobe test]# date "+%Y-%m-%d %H: 阅读全文
posted @ 2020-10-05 20:42 小鲨鱼2018 阅读(376) 评论(0) 推荐(0)
摘要:1、创建测试数据 [root@linuxprobe test]# echo "aaa.bbb.ccc.ddd" > a.txt [root@linuxprobe test]# cat a.txt aaa.bbb.ccc.ddd 2、利用\进行转义,使转义字符仍为字符串 [root@linuxprob 阅读全文
posted @ 2020-10-05 13:32 小鲨鱼2018 阅读(17209) 评论(0) 推荐(0)
摘要:1、简单用法,直接加数字 [root@linuxprobe test]# seq 10 ## 输出1到10列表 1 2 3 4 5 6 7 8 9 10 2、设置起点、终点 [root@linuxprobe test]# seq 5 10 ##设置起点为5,终点为10,默认的步长为1。 5 6 7 阅读全文
posted @ 2020-10-05 12:47 小鲨鱼2018 阅读(922) 评论(0) 推荐(0)
摘要:1、*比较常用的通配符,表示匹配任意长度的任意字符 创建测试数据: [root@linuxprobe test]# touch {1..3}.txt {1..3}.csv {1..3}.xxx ## 利用touch常见空文件 [root@linuxprobe test]# ls 1.csv 1.tx 阅读全文
posted @ 2020-10-05 11:13 小鲨鱼2018 阅读(4334) 评论(0) 推荐(0)
摘要:1、标准输入重定向0,通常省略;标准输出重定向1,通常省略;标准错误输出重定向2,不能省略 创建测试数据 [root@linuxprobe test]# echo 'this is a test!' > a.txt[root@linuxprobe test]# lsa.txt[root@linuxp 阅读全文
posted @ 2020-10-04 23:04 小鲨鱼2018 阅读(1752) 评论(0) 推荐(1)
摘要:1、创建测试数据 [root@linuxprobe test]# cat a.txt e i j s e f s d g e d d 2、利用grep命令统计字符e出现的次数 [root@linuxprobe test]# grep -o "e" a.txt | wc -l 3 3、同时统计e和d出 阅读全文
posted @ 2020-10-03 18:15 小鲨鱼2018 阅读(1884) 评论(0) 推荐(0)
摘要:1、使用vim编辑器创建测试数据 [root@linuxprobe test]# cat a.txt ewetrte fsdfgf dfghghj dsffgd hgfdwe 2、统计每一行f出现的次数 [root@linuxprobe test]# awk -F "f" '{print NF-1} 阅读全文
posted @ 2020-10-03 18:04 小鲨鱼2018 阅读(4340) 评论(0) 推荐(2)
摘要:1、创建测试数据 [root@linuxprobe test]# dd if=/dev/zero bs=1024 count=40000 of=c.txt [root@linuxprobe test]# dd if=/dev/zero bs=1024 count=4000 of=d.txt [roo 阅读全文
posted @ 2020-10-03 17:53 小鲨鱼2018 阅读(992) 评论(0) 推荐(0)