Chinaunix首页 | 论坛 | 博客
  • 博客访问: 984783
  • 博文数量: 584
  • 博客积分: 2293
  • 博客等级: 大尉
  • 技术积分: 3045
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-28 11:15
文章分类

全部博文(584)

文章存档

2012年(532)

2011年(47)

2009年(5)

我的朋友

分类:

2009-05-27 10:57:24

转载自:http://blog.sina.com.cn/s/blog_4735fd9e0100cfgp.html

UNIX-Command by jensen

  内容比较多,只是开头一小部分,sina的BLOG真TM不好用。。。。。 

-------------------------------find-----------------------------------------

 

1.定义 find ..path.. -name ...

find /etc -name hosts

/etc/hosts

/etc/inet/hosts

/etc/net/ticlts/hosts

/etc/net/ticots/hosts

/etc/net/ticotsord/hosts

 

2.精确匹配和模糊匹配

find /etc -name host*

/etc/hosts

/etc/inet/hosts

/etc/net/ticlts/hosts

/etc/net/ticots/hosts

/etc/net/ticotsord/hosts

/etc/hostname.hme0

find /etc -name host

 

find只要不用*,必须精确匹配,差一个字母都不行

find /etc -name hosts find /etc -name host*

 

3.查找目录  find ... -name ... -type d

find /etc -name net*

/etc/inet/netmasks

/etc/inet/networks

/etc/init.d/network

/etc/net

/etc/netmasks

/etc/networks

/etc/netconfig

find /etc -name net* -type d

/etc/net

普通find包括文件,目录,

-type d则只包括目录,不包括文件

 

----------------------------------------grep------------------------------------

1.定义   grep [-v] pattern filename

1.1 单文件查找

hosts中查找含有192.168的行,

grep 192.168 hosts

192.168.183.2   sxuno   loghost

192.168.183.1   sxomc1 sxomc    omc omcr

192.168.83.12   sx-1    mmi_ll  

 

1.2 单文件反查找 -V

hosts中查找不含有192.168的行

grep -v 192.168 hosts

#

Internet host table

#

127.0.0.1       localhost       

200.31.17.252   shcdma

 

1.3 多文件查找

/etc目录中每个文件中,查找含有192.168的行 etc,查找含有192.168的文件,并显示每个含有192.168的行

grep 192.168 /etc/*

/etc/defaultrouter:192.168.183.240

/etc/hosts:192.168.183.2        sxuno   loghost

/etc/hosts:192.168.183.1        sxomc1 sxomc    omc omcr

/etc/hosts:192.168.83.12        sx-1    mmi_ll  

grep: can't open /etc/initpipe

/etc/netmasks:192.168.183.0     255.255.255.0

grep: can't open /etc/opasswd

grep: can't open /etc/shadow

grep: can't open /etc/utmppipe

 

1.4 ls /etc/* grep 192.168 /etc/* 

ls /etc/* grep 192.168 /etc/*

defaultrouter:192.168.183.240

hosts:192.168.183.2     sxuno   loghost

hosts:192.168.183.1     sxomc1 sxomc    omc omcr

hosts:192.168.83.12     sx-1    mmi_ll  

grep: can't open initpipe

netmasks:192.168.183.0  255.255.255.0

grep: can't open opasswd

grep: can't open shadow

grep: can't open utmppipe


阅读(1818) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~