Difference between pages "TroubleShooting network" and "Grep"
From Linuxintro
(Difference between pages)
imported>ThorstenStaerk |
imported>ThorstenStaerk |
||
Line 1: | Line 1: | ||
− | + | * Show all lines that do '''not''' contain blabla | |
+ | grep -v blabla filename.txt | ||
− | + | * Match any character | |
− | + | With a dot (.) you can match any character | |
− | + | grep -E "L.nux" | |
− | + | Matches Linux, Lanux L nux, but not Lnux | |
− | + | * Match all characters | |
+ | With a .* you can match an arbitrary count of any character | ||
+ | grep -E "L.*nux" | ||
+ | Matches Linux, Liinux, Lanux, L nux and Lnux | ||
− | + | * Match any character but blank | |
− | + | grep -E "L[^ ]nux" | |
− | + | Match Linux, Lanux, but not Lnux and not L nux | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
= See also = | = See also = | ||
− | * [[ | + | * [[regex]] |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 08:58, 12 May 2009
- Show all lines that do not contain blabla
grep -v blabla filename.txt
- Match any character
With a dot (.) you can match any character
grep -E "L.nux"
Matches Linux, Lanux L nux, but not Lnux
- Match all characters
With a .* you can match an arbitrary count of any character
grep -E "L.*nux"
Matches Linux, Liinux, Lanux, L nux and Lnux
- Match any character but blank
grep -E "L[^ ]nux"
Match Linux, Lanux, but not Lnux and not L nux