2019独角兽企业重金招聘Python工程师标准>>>

shallow丿ove


特殊符号

  • *任意个任意字符

  • ?任意一个字符

  • #注释字符

  • \脱义字符

  • |管道符

  • cut分割,-d分隔符,-f指定段号,-c指定第几个字符

  • sort排序,-n以数字排序,-r反序,-t分隔符 -kn1/-kn1,n2

  • wc -l统计行数,-m统计字符数,-w统计词

  • uniq去重,-c统计行数

  • tee和>类似,重定向的同时还在屏幕显示

  • tr替换字符,tr 'a''b',大小写替换tr '[a-z]''[A-Z]'

  • split切割,-b大小(默认单位字节),-l行数

cut

[root@localhost ~]# cat /etc/passwd | head -2root:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologin
[root@localhost ~]# cat /etc/passwd | head -2 | cut -d ":" -f 1  #截取第一段,-d表示以":"分隔符rootbin
[root@localhost ~]# cat /etc/passwd | head -2 | cut -d ":" -f 2  #截取第二段xx
[root@localhost ~]# cat /etc/passwd | head -2 | cut -d ":" -f 1,2    #截取第一、二段root:xbin:x
[root@localhost ~]# cat /etc/passwd | head -2 | cut -d ":" -f 1,3    #截取第一、三段root:0bin:1
[root@localhost ~]# cat /etc/passwd | head -2 | cut -d ":" -f 1-3    #截取第一到三段段root:x:0bin:x:1
[root@localhost ~]# cat /etc/passwd | head -2 | cut -c 4t:

awk

sort

按ASCII码排序

[root@localhost ~]# cat /etc/passwd | head | cut -d ":" -f 1 > 1.txt
[root@localhost ~]# cat 1.txtrootbindaemonadmlpsyncshutdownhaltmailoperator
[root@localhost ~]# sort 1.txtadmbindaemonhaltlpmailoperatorrootshutdownsync

按数字排序,其他字符视为0

[root@localhost ~]# cat /etc/passwd | head | cut -d ":" -f 3,4 > 1.txt
[root@localhost ~]# cat 1.txt0:01:12:23:44:75:06:07:08:1211:0
[root@localhost ~]# sort -n 1.txt0:01:111:02:23:44:75:06:07:08:12

按反序排序-r

[root@localhost ~]# sort -rn 1.txt11:08:127:06:05:04:73:42:21:10:0

分隔-t


wc

[root@localhost ~]# wc -l 1.txt10 1.txt
[root@localhost ~]# echo 123 > 1.txt
[root@localhost ~]# echo abc >> 1.txt
[root@localhost ~]# cat 1.txt123abc
[root@localhost ~]# wc -m 1.txt8 1.txt
[root@localhost ~]# cat -A 1.txt123$abc$

换行符

以空白字符分隔

uniq

[root@localhost ~]# cat 1.txt123abc1111111222222211111112222222asdabc[root@localhost ~]# uniq 1.txt123abc1111111222222211111112222222asdabc[root@localhost ~]# vi 1.txt
[root@localhost ~]# cat 1.txt123abc111111111111112222222asdabc[root@localhost ~]# uniq 1.txt123abc11111112222222asdabc

先排序再去重

[root@localhost ~]# sort 1.txt | uniq11111111232222222abcasd

统计

[root@localhost ~]# sort 1.txt | uniq -c1 2 11111111 1231 22222222 abc1 asd

tee输出重定向

[root@localhost ~]# sort 1.txt | uniq -c | tee 2.txt1 2 11111111 1231 22222222 abc1 asd
[root@localhost ~]# cat 2.txt 1 2 11111111 1231 22222222 abc1 asd

tee -a追加输出重定向

[root@localhost ~]# sort 1.txt | uniq -c | tee -a 2.txt1 2 11111111 1231 22222222 abc1 asd
[root@localhost ~]# cat 2.txt 1 2 11111111 1231 22222222 abc1 asd1 2 11111111 1231 22222222 abc1 asd

tr命令

[root@localhost ~]# echo "helloworld" | tr 'h' 'H'Helloworld
[root@localhost ~]# echo "helloworld" | tr '[hw]' '[HW]'HelloWorld
[root@localhost ~]# echo "helloworld" | tr '[a-z]' '[A-Z]'HELLOWORLD

切割命令split

针对大小-b,不加单位默认字节

[root@localhost ~]# find /etc/ -type f -name "*conf" -exec cat {} >> 1.txt \;
[root@localhost ~]# du -sh 1.txt224K   1.txt
[root@localhost ~]# mv 1.txt 111/
[root@localhost ~]# cd 111
[root@localhost 111]# ls1.txt

不指定

[root@localhost 111]# split -b 1000 1.txt
[root@localhost 111]# ls1.txt  xal  xax  xbj  xbv  xch  xct  xdf  xdr  xed  xep  xfb  xfn  xfz  xgl  xgx  xhj  xhv  xihxaa    xam  xay  xbk  xbw  xci  xcu  xdg  xds  xee  xeq  xfc  xfo  xga  xgm  xgy  xhk  xhw  xiixab    xan  xaz  xbl  xbx  xcj  xcv  xdh  xdt  xef  xer  xfd  xfp  xgb  xgn  xgz  xhl  xhx  xijxac    xao  xba  xbm  xby  xck  xcw  xdi  xdu  xeg  xes  xfe  xfq  xgc  xgo  xha  xhm  xhy  xikxad    xap  xbb  xbn  xbz  xcl  xcx  xdj  xdv  xeh  xet  xff  xfr  xgd  xgp  xhb  xhn  xhz  xilxae    xaq  xbc  xbo  xca  xcm  xcy  xdk  xdw  xei  xeu  xfg  xfs  xge  xgq  xhc  xho  xia  ximxaf    xar  xbd  xbp  xcb  xcn  xcz  xdl  xdx  xej  xev  xfh  xft  xgf  xgr  xhd  xhp  xib  xinxag    xas  xbe  xbq  xcc  xco  xda  xdm  xdy  xek  xew  xfi  xfu  xgg  xgs  xhe  xhq  xic  xioxah    xat  xbf  xbr  xcd  xcp  xdb  xdn  xdz  xel  xex  xfj  xfv  xgh  xgt  xhf  xhr  xid  xipxai    xau  xbg  xbs  xce  xcq  xdc  xdo  xea  xem  xey  xfk  xfw  xgi  xgu  xhg  xhs  xie  xiqxaj    xav  xbh  xbt  xcf  xcr  xdd  xdp  xeb  xen  xez  xfl  xfx  xgj  xgv  xhh  xht  xif  xirxak    xaw  xbi  xbu  xcg  xcs  xde  xdq  xec  xeo  xfa  xfm  xfy  xgk  xgw  xhi  xhu  xig  xis
[root@localhost 111]# rm -f x*
[root@localhost 111]# ls1.txt
[root@localhost 111]# split -b 100K 1.txt
[root@localhost 111]# ls1.txt  xaa  xab  xac
[root@localhost 111]# du -sh *224K 1.txt100K   xaa100K xab24K  xac

指定

[root@localhost 111]# rm -f x*
[root@localhost 111]# split -b 100K 1.txt 1-
[root@localhost 111]# ls1-aa  1-ab  1-ac  1.txt

针对行-l

[root@localhost 111]# rm -f *x
[root@localhost 111]# wc -l 1.txt 5736 1.txt
[root@localhost 111]# split -l 1000 1.txt 1-
[root@localhost 111]# ls -ltotal 452-rw-r--r--. 1 root root  44490 Nov 17 07:20 1-aa-rw-r--r--. 1 root root  44233 Nov 17 07:20 1-ab-rw-r--r--. 1 root root  43363 Nov 17 07:20 1-ac-rw-r--r--. 1 root root  36299 Nov 17 07:20 1-ad-rw-r--r--. 1 root root  35017 Nov 17 07:20 1-ae-rw-r--r--. 1 root root  22988 Nov 17 07:20 1-af-rw-r--r--. 1 root root 226390 Nov 17 07:13 1.txt

特殊符号

[root@localhost ~]# for i in `seq 1 10`> do> echo $i> done12345678910
[root@localhost ~]# for i in `seq 1 10`; do echo $i; done12345678910
[root@localhost ~]# ls 111 ; wc -l 1.txt 1-aa  1-ab  1-ac  1-ad  1-ae  1-af  1.txt5736 1.txt

~用户家目录,而在正则表达式中表示匹配符

&放在命令后面,指将命令丢到后台

[root@localhost ~]# ls 111 || wc -l 1.txt   #或1-aa  1-ab  1-ac  1-ad  1-ae  1-af  1.txt
[root@localhost ~]# ls 1111 || wc -l 1.txt ls: cannot access 1111: No such file or directory5736 1.txt
[root@localhost ~]# ls 111 && wc -l 1.txt     #与1-aa  1-ab  1-ac  1-ad  1-ae  1-af  1.txt5736 1.txt
[root@localhost ~]# ls 1111 && wc -l 1.txt ls: cannot access 1111: No such file or directory
[root@localhost ~]# [ -d hello ] || mkdir hello
[root@localhost ~]# lshello  anaconda-ks.cfg
[root@localhost ~]# [ -d hello ] && mkdir hellomkdir: cannot create directory ‘hello’: File exists
[root@localhost ~]# [ -d hello ] || mkdir hello

转载于:https://my.oschina.net/u/3892756/blog/3056528

【CentOS 7笔记35】,几个特殊符号和一些常用命令#相关推荐

  1. Linux学习笔记(一)(服务器环境搭配 常用命令 文件属性)

    Linux学习笔记(一) 概述 Linux发行版 Linux应用 Linux系统运行级别 远程环境配置 连接服务器 安装宝塔 配置环境 测试 测试连接Tomcat 测试访问网站 测试上传 学习Linu ...

  2. 【CentOS 7笔记35】,几个特殊符号和一些常用命令#171117

    2019独角兽企业重金招聘Python工程师标准>>> 特殊符号 *任意个任意字符 ?任意一个字符 #注释字符 \脱义字符 |管道符 cut分割,-d分隔符,-f指定段号,-c指定第 ...

  3. ROS学习笔记2(ROS文件系统和ROS常用命令)

    文章目录 1 预备工作 2 ros包文件系统概览 3 文件系统工具 3.1 rospack 3.2 roscd 3.3 roscd log 3.4 rosls 3.5 tab代码补全 4 总结 1 预 ...

  4. Linux(CentOS)学习笔记

    Linux (CentOS 7)笔记 1. Linux 目录的作用 目录名 目录作用 /bin 存放系统命令的目录, 普通用户和超级用户都可以执行. 不过放在/bin下的命令在单用户模式下也可以执行. ...

  5. 笔记35 笨办法学python练习42对象、类、从属关系和部件关系

    笔记35 笨办法学python练习42对象.类.从属关系和部件关系 一.类.对象与从属关系 这个练习是一个有点哲学意味的练习,讨论对象和类的关系,也就是从属关系.对象不就是下属于某个类的子类,或者个体 ...

  6. Centos学习笔记

    CENTOS学习笔记: 一.shell 脚本基础-bash变量和逻辑运行 1. 终端:附着在终端上的接口程序 GUI:KDE ,GNone,Xfce CLI: /etc/shells bash zsh ...

  7. 任务和特权级保护(四)——《x86汇编语言:从实模式到保护模式》读书笔记35

    任务和特权级保护(四)--<x86汇编语言:从实模式到保护模式>读书笔记35 7. 正式进入用户程序的局部空间 67 mov ebx,message_1 68 call far [fs:P ...

  8. Linux从头开始学--学习笔记9知识点补充-ubuntu,centos;在linux上创建c程序;linux基础命令,shell命令,vi命令,man帮助手册

    这是我从头开始学习Linux的学习笔记,后续还会更新. 记录自己的技术成长,也希望和大家分享交流,欢迎关注~ 本笔记为coursera网站课程<Linux for Developers>的 ...

  9. 第二课 预习内容笔记(centos 系统安装与常用命令解读)

    2018.7.26直播课堂笔记 两天过起来非常快,也非常充实,在做的东西有点多,这才刚开始,想想后面应该要更加加倍预习和学习! 1.1今天的直播课程首先是介绍了操作系统有哪些:一般操作系统分类为:wi ...

最新文章

  1. 南农Nature Microbiology一作顾少华:我与铁载体的这5年
  2. 跨境电商自建站后台系统原型rp_Shoptago---跨境电商平台又一个新选择
  3. 搭建高吞吐量 Kafka 分布式发布订阅消息 集群
  4. 文献记录(part36)--A survey on heterogeneous network representation learning
  5. css3渐变画斜线 demo
  6. 如何在Mac系统中将照片设置为自动播放以及快速更改壁纸的方法
  7. centos卸载nvidia驱动_nvidia驱动的卸载和重新安装
  8. 计算机wps基础知识,计算机考试WPSOffice常见知识点
  9. 背着房贷被裁员是一种什么样的体验?
  10. 轻松一下:python(turtle模块)绘制分形图
  11. csc函数(csc函数值)
  12. 为什么要配置环境变量,配置环境变量有什么好处?
  13. MATLAB矩阵的建立
  14. 函数最值题目及答案_函数的最值与导数综合测试题(附答案)
  15. LCD显示屏的优势与缺点浅析
  16. VBox安装xp虚拟机无法上网
  17. Spring之AOP报错:Null return value from advice does not match primitive return type for
  18. 开心网存在重大安全隐患
  19. 汉字的unicode码范围是多少?
  20. 武警二路擒敌拳16式

热门文章

  1. 2021年度人类社会发展十大科学问题发布
  2. Cerebras发布全球首个人类大脑规模的AI解决方案
  3. 论文《城市大脑的定义与建设规范探讨》在IEEE(ICBAIE)发表
  4. 论文速读:AI能从人类的愚蠢中学到什么?
  5. Gartner 2019年人工智能成熟度曲线的超前趋势
  6. Gartner 2019 年供应链技术八大趋势:AI、高级分析、物联网、RPA、自主设备、数字孪生...
  7. 2018全球最强物联网公司榜单揭晓|20家企业物联网战略大起底!
  8. 预测性智能的力量:AI 和机器学习将如何改变美国政府决策?
  9. 化解谷歌AI霸权的另一种思路?开发平台的生态围剿
  10. 《当代 95 后の北上广出逃计划》