To find lines containing an uppercase letter, followed by four lowercase letters, a comma, spaces, and another uppercase letter in Linux, use the following grep command:

grep '[A-Z][a-z]{4},[[:space:]]*[A-Z]' filename

This command uses regular expressions to match the desired pattern:

  • [A-Z]: Matches any uppercase letter.* [a-z]{4}: Matches four lowercase letters.* ,: Matches a comma.* [[:space:]]*: Matches any number of spaces.* [A-Z]: Matches another uppercase letter.

Replace filename with the name of the file you want to search. This command will output all lines that contain the specified pattern.

Linux grep: Find Lines with Specific Pattern (Uppercase, Lowercase, Comma, Uppercase)

原文地址: https://www.cveoy.top/t/topic/jJKM 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录