https://github.com/astrodynamic/greputility
This is a grep utility project that searches for a pattern in files and outputs matching lines. It supports various flags and is built with CMake and Makefile.
https://github.com/astrodynamic/greputility
c cmake grep makefile posix utility
Last synced: 11 months ago
JSON representation
This is a grep utility project that searches for a pattern in files and outputs matching lines. It supports various flags and is built with CMake and Makefile.
- Host: GitHub
- URL: https://github.com/astrodynamic/greputility
- Owner: Astrodynamic
- License: mit
- Created: 2023-05-04T04:43:47.000Z (over 2 years ago)
- Default Branch: develop
- Last Pushed: 2023-05-04T04:46:33.000Z (over 2 years ago)
- Last Synced: 2025-01-12T18:09:45.566Z (12 months ago)
- Topics: c, cmake, grep, makefile, posix, utility
- Language: C
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GrepUtility
GrepUtility is a simple command-line utility written in C, that searches files for lines matching a regular expression pattern and prints them to the console.
## Build
To build the GrepUtility, please make sure you have the following dependencies installed:
- CMake 3.10 or higher
- GCC or Clang compiler
- PCRE or Regex libraries
### Makefile Targets
- `all`: build the program
- `build`: build the program
- `rebuild`: clean and rebuild the program
- `install`: install the program
- `unistall`: remove the installed program
- `clean`: remove build and library files
- `cppcheck`: run cppcheck on the source code
- `clang-format`: format the source code using clang-format
Makefile goals description:
- `all`: it's the default target, which builds the program.
- `build`: it's a target that builds the program.
- `rebuild`: it's a target that cleans the previous build, builds and installs the program.
- `install`: it's a target that installs the program in the system.
- `unistall`: it's a target that uninstalls the program from the system.
- `clean`: it's a target that removes all the build
To build the utility, run the following commands:
```sh
make all
cd build
```
## Usage
To use GrepUtility, run the following command:
```sh
GrepUtility [options] pattern [file_name]
```
Here are the available options:
- `-e pattern`: Use `pattern` as the search pattern.
- `-i`: Ignore case distinctions in both the pattern and the input files.
- `-v`: Invert the sense of matching, to select non-matching lines.
- `-c`: Only output the count of matching lines.
- `-l`: Only output the names of files containing at least one matching line.
- `-n`: Prefix each line of output with its 1-based line number within its input file.
- `-h`: Never print filename headers (i.e. file names) with output lines.
- `-s`: Suppress error messages about nonexistent or unreadable files.
- `-f file`: Obtain patterns from file, one per line.
## Dependencies
- CMake 3.10 or higher
- GCC or Clang compiler
- PCRE or Regex libraries
## Development
The source code, header files, and build files are located in the `model/` directory. The code follows the principles of structured programming and avoids code duplication.
Integration tests cover all flag variants and input values, based on a comparison with the behavior of real Bash utilities.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.