0

How can you count the number of the character < in your files?

I am trying to count the number of the character "<" in my files, similarly as in Vim by

%s/<//gn

I run

 find * -type f | xargs sed 's/<//gn'

I get

sed: -e expression #1, char 7: unknown option to `s'

This error suggests me that Vim's :s -mode is not like SED.

Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697

2 Answers2

2

I'm not familiar with the n option in Vim, but yes, sed does not support the n option. Here's another way you could count the number of instances of the < character in your files:

find * -type f | xargs cat | tr -d -c '<' | wc -c

The tr -d -c '<' command deletes all characters that are not <, and then wc -c counts the number of remaining characters.

Adam Rosenfield
  • 390,455
  • 97
  • 512
  • 589
0
grep -RoE "<" * |wc -l
ghostdog74
  • 327,991
  • 56
  • 259
  • 343