Skip to content

Grep Chart: List strings that match a pattern in file(s), with and sorted by the amount of occurrences.

License

Notifications You must be signed in to change notification settings

kstenschke/grepc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grep Chart

Build Status Language grade: C/C++ CodeFactor

Synopsis

grepc PATTERN [FILE]
grepc -v PATTERN [FILE] grepc -m=<MIN_OCCURRENCES> PATTERN [FILE]

PATTERN = an extended regular expression (ERE).
FILE = a relative or absolute path to a file or directory.

Description

grepc searches for PATTERN in each FILE. If no FILE is given, recursively searches the working directory.
grepc prints all matches and their amount of occurrences.
Printed matches are sorted: 1. descending by amount of occurrences, 2. ascending alphabetically by matching string.

Table of Contents

Options

-m=, --min=

Minimum amount of occurrences. Matching string with less occurrences than the given amount are not printed.

-v, --verbose

Print a results summary additionally to the grep chart:

  • amount of total matches
  • amount of matching strings
  • amount of files searched

-V, --version

Print information about installed version of grepc, its license and author(s).

Usage examples

Find strings wrapped in double quotes, sorted by popularity

Find strings that are enclosed in double quotes, with a minimum length of ten characters:

grepc '"[A-Za-z ]{10,}"' ./src

Output e.g.:

156 "White Christmas"
155 "Candle in the Wind"
154 "In the Summertime"
153 "I will always love you"
152 "Rock around the Clock"
151 "Its now or never"
150 "We are the world"

Note: to find strings that are enclosed in single quotes, these must be escaped as: '\''.
E.g.: grepc "'\''[A-Za-z]{4,}'\''"

Find floating numbers sorted by popularity

Find floating numbers that have at least 14 decimal places.

grepc -v '(\d\.\d+){16,}' ./src

Output e.g.:

Found 177 matches in 83 out of 90 files.
There are 2 different matching strings:

91 3.14159265358979
86 2.71828182845904

Build from source

cmake CMakeLists.txt; make

Install

Build from source, than: sudo make install

Conventions

The source code of grepc follows the Google C++ Style Guide, see: https://google.github.io/styleguide/cppguide.html

grepc follows the Semantic Versioning Scheme.

Changelog

See CHANGELOG.md

Used third party applications

Application License
GNU Grep GNU General Public License
GNU wc GNU General Public License

Author and License

grepc was written by Kay Stenschke and is licensed under the GNU General Public License V3.0

Permissions of this strong copyleft license are conditioned on making available 
complete source code of licensed works and modifications, which include larger 
works using a licensed work, under the same license. Copyright and license 
notices must be preserved. Contributors provide an express grant of patent 
rights.

About

Grep Chart: List strings that match a pattern in file(s), with and sorted by the amount of occurrences.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published