Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何快速确定文件中以大写字母开头的行数?
我认为使用正则表达式这将是 [AZ]*),但我不想“读取行”……更快。
如果您不想使用read循环,最好的选择是使用grep,使用-c计算匹配行的开关,如下所示:
read
grep
-c
grep -c ^[A-Z] the_file.txt