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 13:59] – [wordscapes] raju | grep_usage [2023/09/07 21:03] (current) – [repeat previous character N times] raju | ||
---|---|---|---|
Line 1: | Line 1: | ||
==== dummy ==== | ==== dummy ==== | ||
+ | * [[Remove lines with duplicate letters]] | ||
* [[grep on find results]] | * [[grep on find results]] | ||
Line 12: | Line 13: | ||
Remove lines with duplicate letters | Remove lines with duplicate letters | ||
< | < | ||
- | % grep -i " | + | % grep -Ei " |
... | ... | ||
shire | shire | ||
Line 21: | Line 22: | ||
compare this with | compare this with | ||
< | < | ||
- | % grep -i " | + | % grep -Ei " |
... | ... | ||
shire | shire | ||
Line 31: | 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 55: | 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.1691762355.txt.gz · Last modified: 2023/08/11 13:59 by raju