shell-commands
来源:互联网 发布:大数据与经济发展 编辑:程序博客网 时间:2024/06/11 17:05
- ls
- lsof
- find
- iotop
- free
- bufferscached
- awk
- split
- xargs
- 正则表达式
- 语法
- 两种模式
ls
lsof
lsof -c apa
-c后面的指令可以不用写完
find
按文件类型查找: -type f
按名字查找: -name *.txt
[root@test05 ab]# find . -type f -name "*.txt" [root@test05 ab]#
按大小来找 -size
# find / -size +30M# 其中30前面的+-号代表,大于小于;
iotop
free
$free -m total used free shared buffers cachedMem: 48262 7913 40349 0 14 267-/+ buffers/cache: 7631 40631Swap: 2047 336 1711# 上面的情况下我们总的内存有48262M,用掉了7913M(其中包括了buffers+cached)。# 其中buffer+cache总共14+267=281M, 由于这种类型的内存是可以回收的,虽然我们用掉了7913M,但是实际上我们如果实在需要的话,这部分buffer/cache内存是可以放出来的。# buffer: 作为buffer cache的内存,是块设备的读写缓冲区# cache: 作为page cache的内存, 文件系统的cache
buffers/cached
缓存(cache)是把读取过的数据保存起来,重新读取时若命中(找到需要的数据)就不要去读硬盘了,若没有命中就读硬盘。其中的数据会根据读取频率进行组织,把最频繁读取的内容放在最容易找到的位置,把不再读的内容不断往后排,直至从中删除。 ——-把频繁读取的数据cache起来
缓冲(buffers)是根据磁盘的读写设计的,把分散的写操作集中进行,减少磁盘碎片和硬盘的反复寻道,从而提高系统性能。linux有一个守护进程定期清空缓冲内容(即写如磁盘),也可以通过sync命令手动清空缓冲。 —–把分散写集中进行
[root@server test]# sync[root@server test]# echo 3 > /proc/sys/vm/drop_caches# To free pagecache, use 1# to free dentries and inodes, use 2# to free pagecache, dentries and inodes, use echo 3
awk
split
The awk function split(s,a,sep) splits a string s into an awk array a using the delimiter sep.
awk ‘{pattern + action}’ {filenames}
root@pythonLang# echo `echo "<Hlz>value</Hlz>" | awk '{split($0, arr, "<|>"); print arr[3]}'`valueroot@pythonLang# dateSat Jun 10 16:07:15 HKT 2017root@pythonLang# echo `echo $(date) | awk '{split($0,a,":" ); for (i=1; i<=3; i++) print a[i]}'` Sat Jun 10 16 07 16 HKT 2017
xargs
参数 -i/I
[root@test05 ab]# find . -type f -name "*.txt" | xargs -i cp {} /tmp/k/#加-i 参数直接用 {}就能代替管道之前的标准输出的内容;[root@test05 ab]#[root@test05 ab]# find . -type f -name "*.txt" | xargs -I {} cp {} /tmp/n/#加 -I 参数 需要事先指定替换字符
正则表达式
语法
两种模式
贪婪模式:匹配尽可能多的字符(默认执行);
懒惰模式:匹配尽可能少的字符;— 在原有的基础上加?即可;
阅读全文
0 0
- Shell Commands
- Shell commands
- shell-commands
- UNIX Shell Commands List
- shell commands (continued)
- Hadoop Shell Commands
- HBase shell commands
- some shell commands
- HBase shell commands
- Shell & Linux commands reference
- mongodb shell commands
- HBase shell commands
- adb shell commands
- Running shell commands from Emacs
- basic and common shell commands
- ADB Shell Commands,个人翻译,多多指点
- 利用commands模块执行Linux shell命令
- android开发笔记之ADB Shell Commands
- 关于SpringDataJPA的一些小知识
- Hdu A+B for Input-Output Practice (VII)
- Java指定保留小数位数的方法
- 解决Python字符串显示u'...'的问题
- 虚函数
- shell-commands
- java中的占位符
- bzoj 1051简单tarjan
- CLR via C# 读书笔记 6-2 不同AppDomain之间的通信
- Prim & Kruskal Algorithm
- [bzoj2038][2009国家集训队]小Z的袜子(hose) 莫队算法
- 第七章 为什么巴比伦塔会失败
- shell-keys
- [leetcode]583. Delete Operation for Two Strings