grep_usage
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
grep_usage [2023/08/11 14:40] – [dummy] raju | grep_usage [2023/09/07 21:03] (current) – [repeat previous character N times] raju | ||
---|---|---|---|
Line 13: | Line 13: | ||
Remove lines with duplicate letters | Remove lines with duplicate letters | ||
< | < | ||
- | % grep -i " | + | % grep -Ei " |
... | ... | ||
shire | shire | ||
Line 22: | Line 22: | ||
compare this with | compare this with | ||
< | < | ||
- | % grep -i " | + | % grep -Ei " |
... | ... | ||
shire | shire | ||
Line 32: | Line 32: | ||
skies | skies | ||
</ | </ | ||
+ | |||
which also shows words where some letters are repeated twice. | which also shows words where some letters are repeated twice. | ||
Line 56: | Line 57: | ||
% grep -Ei " | % grep -Ei " | ||
unused | unused | ||
+ | </ | ||
+ | |||
+ | ==== print lines with less than a certain number of characters ==== | ||
+ | To print lines that contain less than N characters | ||
+ | < | ||
+ | grep -Ev " | ||
+ | </ | ||
+ | |||
+ | For example: | ||
+ | To print lines that contain less then 6 characters | ||
+ | < | ||
+ | grep -Ev " | ||
+ | </ | ||
+ | |||
+ | You can also do | ||
+ | < | ||
+ | grep -v " | ||
+ | </ | ||
+ | where the . is repeated N times. This is easier to type for small N. | ||
+ | |||
+ | Sample run: | ||
+ | < | ||
+ | $ cat data.txt | ||
+ | a | ||
+ | ab | ||
+ | abc | ||
+ | abcd | ||
+ | abcde | ||
+ | abcdef | ||
+ | abcdefg | ||
+ | |||
+ | $ grep -v " | ||
+ | a | ||
+ | ab | ||
+ | abc | ||
+ | abcd | ||
+ | abcde | ||
+ | |||
+ | $ grep -Ev " | ||
+ | a | ||
+ | ab | ||
+ | abc | ||
+ | abcd | ||
+ | abcde | ||
</ | </ | ||
grep_usage.1691764850.txt.gz · Last modified: 2023/08/11 14:40 by raju