grepは与えられた行でn個以上のピリオドを探します。

grepは与えられた行でn個以上のピリオドを探します。

次のように、多くのピリオドを含む行をランダムに一致させることができます。

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

私はこれを盲目的に試しました。

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

それからある程度効果があると知っていたことを試してみました。

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

しかし、[[:punct:]]{\4,\}残念ながらgrepが見逃してコマンドをキャンセルしますgrep -v

これを行っても、grep -P '\.{4,}'次のように私が見つけようとしている行は返されません。

    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;

最初の行には10個のピリオドが含まれています。

ベストアンサー1

grep -E '(.*\.){4}' textfile

これは、分離するかどうかにかかわらず、1行の最小4つのピリオドと一致します。

おすすめ記事