There are many lines containing the >
symbol in a file. How can I count the total number of >
symbols in a file? I have tried sed
and grep
and it did not work.
相关问题
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- Error building gcc 4.8.3 from source: libstdc++.so
- Why should we check WIFEXITED after wait in order
- Null-terminated string, opening file for reading
You can use GNU grep together with
wc
grep -o
prints every match on a separate line.wc
counts the lines.Btw, it's not 100% clear in your question if the
>
can appear only at the start of a line. If you just want to count the lines that start with a>
you can use the following grep command:^
matches the beginning of the line,[[:space:]]*
allows for zero ore more space characters in front of the>
, just in case.