Bash 只计算前面有给定字符的行(<;)

Bash 只计算前面有给定字符的行(<;),bash,csv,unix,Bash,Csv,Unix,我想计算CSV文件中的行数。 但是只有那些带有“grep-E”^的人使用grep和c: grep -c '^<' <FILE> grep-c'^您可以使用awk获得包含'的所有行,Luke: $ cat file foo < this foo not this foo < < another of those foos $ awk '/^</{c++}END{print c}' file 2 $cat文件 福

我想计算CSV文件中的行数。
但是只有那些带有“
grep-E”^的人使用
grep
c

grep -c '^<' <FILE>

grep-c'^您可以使用awk获得包含'的所有行,Luke:

$ cat file
foo
< this foo
not this foo <
< another of those foos
$ awk '/^</{c++}END{print c}' file
2
$cat文件
福
$awk'/^用于最简单、最简单、最相同的:。。。
grep "^<" file.csv | wc -l
$ cat file
foo
< this foo
not this foo <
< another of those foos
$ awk '/^</{c++}END{print c}' file
2