Option | Definition |
-i | Searches for both uppercase ande lowercase characters |
-l | lists the names of files with marching lines |
-n | Precedes each line with the relative line number in the file |
-v | Inverts the search to display lines that do not match th |
-c | Counts the lines that contain the pattern |
-w | Searches for tehe expression as a complete word,ignoring |
Esempi:
1) cerca la stringa root nel file /etc/group e mi restituisce il numero della linea
$ grep -n root /etc/group
1:root::0:
2:other::1:root
3:bin::2:root,daemon
4:sys::3:root,bin,adm
5:adm::4:root,daemon
6:uucp::5:root
7:mail::6:root
8:tty::7:root,adm
9:lp::8:root,adm
10:nuucp::9:root
12:daemon::12:root
$cd /etc
$ grep -l root group passwd hosts
group
passwd
$ grep -c root group
11
0 Commenti:
Posta un commento
<< Home page