List or drop matching lines

Can be done with grep in the shell, of course, but I do it quite a lot, and find it a little quicker to experiment with the help of the simple options of a Keyboard Maestro action. ( Saves me checking man grep for simple things at the command line, and lets me keep to the familiar Javascript dialect of Regular Expressions :- )

List or drop matching lines.zip (10.8 KB)

Custom Keyboard Maestro Plug-in

NAME

  • List or drop matching lines

VERSION

  • 0.1

SYNOPSIS

  • Returns a subset of the input lines

REQUIREMENTS

  • Yosemite
    • The core script listOrDropMatchingLines.sh is mainly written in Javascript for Applications

OPTIONS

  • Source clipboard or variable:
  • Include:
    • ONLY lines matching pattern
    • All EXCEPT matching lines
    • ALL lines
  • Matched line
    • contains
    • is
    • is not
    • begins with
    • ends with
    • matches Regex
  • Pattern
    • ( the literal text or regex pattern to be matched )
  • Ignore case ?
  • Remove blank lines from output ?
    • Can be used in combination with the Include: ALL lines option to simply strip out blank lines from a text
    • Also allows blank lines to pass through regardless of matching

INSTALLATION

  • Drag the .zip file onto the Keyboard Maestro icon in the OS X toolbar.
  • (if updating a previous version of the action, first manually remove the previous copy from the custom actions folder)
    • ~/Library/Application Support/Keyboard Maestro/Keyboard Maestro Actions

CONTACT

3 Likes