首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

Linux学习札记(四)查询排序

2013-01-26 
Linux学习笔记(四)查询排序1.文件查找命令find和locatefind 命令用于查找文件系统中的指定文件其命令格式

Linux学习笔记(四)查询排序

1.  文件查找命令find和locate
find 命令用于查找文件系统中的指定文件其命令格式为
find 要查找的路径表达式
例如:
[root@localhost ~]#find . -name 1.txt 在当前目录及其子目录下查找文件 1.txt
[root@localhost ~]#find /tmp -name 1.txt 在 /tmp 目录及其子目录下查找文件1.txt

2 文件内容查找命令grep
grep 命令用于查找指定的模式匹配格式为
grep [命令选项] 要查找的匹配模式 [要查找的文件]
例如:
[root@localhost ~]#grep cams test.txt                   在 test.txt 文件中查找cams 字符串
[root@localhost ~]#grep -r cams /root/cams        在 /root/cams 目录及其子目录下的所有文件中

[root@localhost ~]#find -name '*.txt'|xargs grep 'E400' 查询语句
[root@localhost ~]#ps -ef | grep ora                     查找进程名中包含 ora 的所有进程信息

3. sort将文件的每一行作为一个单位,相互比较,比较原则是从首字符向后,
依次按ASCII码值进行比较,最后将他们按升序输出
[root@localhost ~]#sort seq.txt         直接升序排序
[root@localhost ~]#sort -r seq.txt    去除重复排序
[root@localhost ~]#sort -u seq.txt    去除重复排序

4. xargs

热点排行
Bad Request.