Skip to content

Document equivalent gnu grep commands for ggrep #35

@Poikilos

Description

@Poikilos

ggrep "os.execute" is equivalent to grep "os.execute" -r -n | sed 's/:\([0-9]\+\)/ -l \1/g' | sed 's/\([0-9]\+\):/\1 #/g' | sed 's/^\(\w\)/geany \1/g'

How the sed commands above work:

  • ^\(w\) means capture the first word (^: next group must be preceeded by nothing) as a group, and geany \1 means place the "geany " command before that group in the output (and \1: place the first group in the output so it is kept)
    (See https://stackoverflow.com/a/31976991/4541104 for the following)
  • regex operators ((, ), +, w) must be escaped to be used as operators (unless using "-r" but that is only available on GNU sed) otherwise they are treated as literals
  • \1 must always be escaped (even with -r) to denote that you want to place the first captured group back into the output
  • [0-9] must be used because GNU sed does not recognize \d for a number.
    • \+ is for one or more of the preceeding group (capture entire number in this case).

The piping or ggrep both translate the output from something like:

worldedit_commands/init.lua:137:        os.execute ('mkdir "' .. path .. '"')

to

geany worldedit_commands/init.lua -l 137  #        os.execute ('mkdir "' .. path .. '"')

and since . is wildcard, all things like os.execute, os_execute, and so on would be found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions