@apexearth/egrep
egrep for node!
Last updated a month ago by apexearth .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @apexearth/egrep 
SYNC missed versions from official npm registry.

egrep

Travis Status Coverage Status NPM Downloads install size License

egrep for Node.js (Extended Global Regular Expressions Print)

Installation

Use with Node.js

$ npm install @apexearth/egrep --save

Use with Command Line

$ npm install @apexearth/egrep -g

Node.js Usage

let egrep = require('@apexearth/egrep')
let stream = egrep({
    pattern: /test[1-9]/,
    files: [
        'test_files/file1.txt',
        'test_files/',
    ],
    recursive: true,
})
stream.on('data', data => {
    console.log(data)
})
stream.on('error', err => {
    console.log(err)
})
stream.on('close', () => {
    console.log('closed')
})

Output:

{ file: 'test_files/file1.txt', line: 'aaaaaaatest4aaaaaaa' }

Use with callback:

egrep({
    pattern: /test[1-9]/,
    files: [
        'test_files/file1.txt',
        'test_files/',
    ],
    recursive: true,
    objectMode: false,
}, (err, result) => {
    if (err) console.log(err)
    console.log(result)
})

Output:

test_files/file1.txt:aaaaaaatest4aaaaaaa

Options

  • files: The files, folders, or globs to grep.
  • pattern: The pattern to grep for.
  • glob: Treat files option as a glob.
  • recursive: Recursively grep through folders.
  • ignoreCase: Perform case insensitive matching.
  • excludes: Array of RegExp exclusions.
  • objectMode: Set false to receive string data.
  • fullBinaryMatches: Set true to display the full binary match.
  • hideBinaryMatches: Set true to hide all binary matches.

Command Line Usage

Usage: node-egrep [options] <pattern> <file...>

Options:
  -V, --version      output the version number
  -r, --recursive    Walk through directories recursively.
  -R, --recursive    Walk through directories recursively.
  -g, --glob         Treat file args as globs.
  -i, --ignore-case  Perform case insensitive matching.
  -f, --file <file>  Read one or more newline separated patterns from file. Empty pattern lines match every input line.
  --exec <cmd>       Execute a command for each match with {1}=file {2}=line
  -h, --help         output usage information

Examples:

$ node-egrep 123 test_files/numbers
1234567890

$ node-egrep -r abc test_files
test_files/one/abc:abcdefg
test_files/one/two/letters:abc

$ node-egrep -g abc "test_files/**"
test_files/one/abc:abcdefg
test_files/one/two/letters:abc

Compatibility

Node.js versions 8, 10, and 11.

Current Tags

  • 1.0.9                                ...           latest (a month ago)

8 Versions

  • 1.0.9                                ...           a month ago
  • 1.0.8                                ...           a month ago
  • 1.0.7                                ...           10 months ago
  • 1.0.6                                ...           a year ago
  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 8
Last Day 0
Last Week 0
Last Month 34
Dependencies (4)
Dev Dependencies (6)

Copyright 2014 - 2017 © taobao.org |