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.

  • 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
grep -E '(.*\.){4}' textfile

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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