Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grep exercise

This excerise deals with a command-line program that implements Unix grep like functionality.

This exercise has been solved in a TDD fashion. Please refer to the execise here.

Features

This program supports searching files, directory recusively, and STDIN. It can also write the output to file, and perform case-sensitive search.

Options are as follows:

  • -r: recursive search in a directory
  • -i: case-sensitive search
  • -o: write output to file
  • -A: print n lines after the match
  • -B: print n lines before the match
  • -C: only print count of matches instead of actual matched lines

Usage

  1. Run the below command to build the binary. It has been saved in the bin directory.
make build
  1. For using the program, arguments and options can be passed as usual. Some examples are as follows:
  • For searching on a single file:
    ./bin/go-grep <search-string> <file-name>
    
  • For searching in a directory recusively:
    ./bin/go-grep <search-string> <file-name> -r
    
  • For searching in a directory recusively and writing output to file:
    ./bin/go-grep <search-string> <file-name> -r -o <output-file>
    

About

one2n go bootcamp- grep exercise

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages