2017-08-04 12 views
-2

CSVファイルの行数をカウントします。 最初は「<」のもののみです。 grepを持つ指定された文字の前に行を数えます(<)

+0

ほぼ同じ:[この質問](https://stackoverflow.com/questions/40395018/counting-lines-starting-with-a-symbolを)、[この質問](https://stackoverflow.com/questions/28899349/find-lines-starting-with-one-specific-character-and-ending-with-another-one)、[この質問](https ://stackoverflow.com/questions/18489846/counting-lines-starting-with-a-word-word)... –

答えて

4

使用grep

grep -c '^<' <FILE> 
+2

up for most straightforward and simplest – Kent

-1
grep -E "^<" filename | wc -l 

使用正規表現は、行数を取得するためにトイレ-lを通る線(^)と、パイプの開始時に<をチェックします。 c

0

あなたはgrep '^<'で初めに「<」を含むすべての行を取得し、wc -lと、残りの行をカウントすることができます。

grep "^<" file.csv | wc -l 
2

awkは、ルークを使用します

$ cat file 
foo 
< this foo 
not this foo < 
< another of those foos 
$ awk '/^</{c++}END{print c}' file 
2 
関連する問題