If you can see this check that

next section prev section up prev page next page

Pattern matching rules

You can use special characters to cause a pattern to match various strings, in much the same way you use wildcard characters in file names to match a variety of filenames.

Examples of grep usage:

% grep '.outing' demofile
% grep 'RFC-97[34]' demofile
% grep -i 'rfc-97[34]' demofile       (-i mean 'case-insensitive')
% grep 'Tw.*on' demofile
% grep 'inf.*' demofile
% grep '^network' demofile
% grep 'routing$' demofile

Common options for the grep command:

You should also note that you can exclude characters with a combination of the caret ^ and square brackets []. For example:

% grep 'J[aei]' names
James
Jane
Jess
Jim

% grep 'J[^aei]' names
Jock
John
Jordan


Centos 7 intro: Paths | BasicShell | Search
Linux tutorials: intro1 intro2 wildcard permission pipe vi essential admin net SELinux1 SELinux2 fwall DNS diag Apache1 Apache2 log Mail
Caine 10.0: Essentials | Basic | Search | Acquisition | SysIntro | grep | MBR | GPT | FAT | NTFS | FRMeta | FRTools | Browser | Mock Exam |
CPD: Cygwin | Paths | Files and head/tail | Find and regex | Sort | Log Analysis
Kali: 1a | 1b | 1c | 2 | 3 | 4a | 4b | 5 | 6 | 7a | 8a | 8b | 9 | 10 |
Kali 2020-4: 1a | 1b | 1c | 2 | 3 | 4a | 4b | 5 | 6 | 7 | 8a | 8b | 9 | 10 |
Useful: Quiz | Forums | Privacy Policy | Terms and Conditions

Linuxzoo created by Gordon Russell.
@ Copyright 2004-2023 Edinburgh Napier University