trainee-go-grep

command module
v0.0.0-...-8c10779 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2020 License: GPL-2.0 Imports: 9 Imported by: 0

README

trainee-grep

About

trainee-grep is a from scratch developed program which outputs a pattern that is found in files you specify. There are various parameters you can use to filter or individualize the output of your to "grepped" file. Seen like this it's an imitation of the original grep command line command.

Note: You cannot use grep without at least the -e parameter which defines the pattern you search for.

Parameters

Parameter Usage
-e Define a pattern for matching.
-F Use the pattern not as a regular expression but as a fixed string.
-w Use pattern that only matches words.
-x Use pattern that only matches whole lines.
-i Ignore case distinctions.
-v Use pattern as non-matching lines.
-q Suppress all normal output.
-m Stop printing after NUM selected lines.
-n Print the line number.
-r Search the pattern in a directory.

Usage Examples

In the following you'll see a quick example of how to use the grep command. Here is what our text file looks like:

toGrep.txt:

            zebra
            zebra
            dog
            zebra
            cat

toGrep2.txt:

            dog
            cat
            cat
            mouse
            zebra

Now we can grep our pattern with ./grep.linux-amd64 -e 'zebra' < toGrep.txt

The output is:

            zebra
            zebra
            zebra

If you want to search for a pattern in more than one file use ./grep.linux-amd64 -e 'zebra' toGrep.txt toGrep2.txt

The output is:

            toGrep.txt:zebra
            toGrep.txt:zebra
            toGrep.txt:zebra
            toGrep2.txt:zebra

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL