pavement

Grep

From FreeBSDwiki
(Difference between revisions)
Jump to: navigation, search
m
m
Line 31: Line 31:
 
Looks like only [[root]] does.
 
Looks like only [[root]] does.
  
 +
See also: [[strings]]
  
 
[[Category:FreeBSD Terminology]] [[Category:System Commands]]
 
[[Category:FreeBSD Terminology]] [[Category:System Commands]]

Revision as of 20:51, 22 December 2004

grep returns results that match a string. You can use it to find a line in a file in a directory, by having grep run through the directory and show you what matches your query. Grep accepts input from the commandline, but is more often fed input in conjunction with other commands, such as find, ls or cat:

samizdata# ls -la /etc | grep .conf
-rw-r--r--   1 root  wheel      1163 Jun  5  2003 apmd.conf
-rw-r--r--   1 root  wheel       271 Jun  5  2003 auth.conf
-rw-r--r--   1 root  wheel      2965 Jun  5  2003 devd.conf
-rw-r--r--   1 root  wheel      2073 Jun  5  2003 devfs.conf
-rw-r--r--   1 root  wheel       267 Jun  5  2003 dhclient.conf
-rw-r--r--   1 root  wheel      5159 Jun  5  2003 inetd.conf
-rw-r--r--   1 root  wheel      6521 Jun  5  2003 login.conf
-rw-r--r--   1 root  wheel     65536 Jun  5  2003 login.conf.db
-rw-r--r--   1 root  wheel       503 Jun  5  2003 mac.conf
-rw-r--r--   1 root  wheel       201 Jun  5  2003 make.conf
-rw-r--r--   1 root  wheel       963 Jun  5  2003 manpath.config
-rw-r--r--   1 root  wheel       963 Jun  5  2003 manpath.config.bak
-rw-r--r--   1 root  wheel       783 Jun  5  2003 netconfig
-rw-r--r--   1 root  wheel      1871 Jun  5  2003 newsyslog.conf
-rw-------   1 root  wheel      1701 Jun  5  2003 nsmb.conf
-rw-r--r--   1 root  wheel       630 Aug 23 21:46 rc.conf
-rw-r--r--   1 root  wheel        45 Jun  5  2003 resolv.conf
-rw-r--r--   1 root  wheel       367 Jun  5  2003 sysctl.conf
-rw-r--r--   1 root  wheel      1329 Jun  5  2003 syslog.conf
-rw-r--r--   1 root  wheel      2023 Jun  5  2003 usbd.conf

Let's say you want to know which of your users has csh as their shell:

samizdata# cat passwd | grep csh
root:*:0:0:Avatar:/root:/bin/csh
samizdata#

Looks like only root does.

See also: strings

Personal tools