Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to be able to arbitrarily match lines that contain a lot of periods, like this:

$ echo "there's. someone on the wing. some. thing." | grep -stuFF [[:idunno:]]{4,}
there's. someone on the wing. some. thing.

I tried, blindly gropingly:

grep -P [[.]]{\4,\} textfile
grep -P \.{\4,\} textfile

and then tried something I knew would work at some level

grep -P [[:punct:]]{\4,\} textfile

but [[:punct:]]{\4,\} disappointingly just picked up a lot of the lines I wanted grep to miss so that I could turn the command around and do a grep -v.

Even doing grep -P '\.{4,}' does not return the lines I am trying to grep for, which look like:

    Sullivan, G.R. Tetrahedron Lett. 1971, 223; Pascal, Jr., R.A.; Winans, C.G.; Van Engen, D. J. Am. Chem.
compounds (i.e., shielding and deshielding of nuclei) can be measured by a simple
Plavic, D.; Babic, D.; Nikolic, S.; Trinajstic, N. Gazz. Chim. Ital., 1993, 123, 243.
Hess, Jr., B.A.; Schaad, L.J. J. Am. Chem. Soc. 1971, 93, 305.
as N-oxides or pyridinium ions are still aromatic. However, for nitrogen heterocycles there are more significan$
given in Coulson, C.A.; Streitwieser, Jr., A. A Dictonary of p Electron Calculations, W.H. Freeman, San
Hydrocarbons, Elsevier, NY, 1987; Clar, E. Polycyclic Hydrocarbons, 2 vols., Academic Press, NY, 1964.
Zhang, J.; Ho, D.M.; Pascal Jr., R.A. J. Am. Chem. Soc. 2001, 123, 10919.
See Herndon, W.C.; Ellzey Jr., M.L. J. Am. Chem. Soc. 1974, 96, 6631.
Dauben Jr., H.J.; Rifi, M.R. J. Am. Chem. Soc. 1963, 85, 3041; also see Breslow, R.; Chang, H.W. J. Am
1973, 1, 29; Kolomnikova, G.D.; Parnes, Z.N. Russ. Chem. Rev. 1967, 36, 735; Harmon, K.H., in Olah,
Bertelli, D.J.; Andrews, Jr., T.G. J. Am. Chem. Soc. 1969, 91, 5280; Bertelli, D.J.; Andrews Jr., T.G.;
Nikitina, T.V. Organomet. React., 1972, 4, 163; Bublitz, D.E.; Rinehart Jr., K.L. Org. React., 1969, 17, 1;

Note that the first of those lines contains 10 periods.

share|improve this question
1  
your \.{4,} and similar patterns are searching for four-or-more consecutive periods. Hosam's answer searches for four-or-more periods, regardless of whether they are consecutive or separated by other characters. –  cas Sep 10 '12 at 9:58

1 Answer 1

up vote 8 down vote accepted
grep -E '(.*\.){4}' textfile

This will match at least 4 periods within a line, separated or not.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.