Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document equivalent gnu grep commands for ggrep #35

Open
Poikilos opened this issue Aug 22, 2023 · 0 comments
Open

Document equivalent gnu grep commands for ggrep #35

Poikilos opened this issue Aug 22, 2023 · 0 comments

Comments

@Poikilos
Copy link
Collaborator

Poikilos commented Aug 22, 2023

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.

@Poikilos Poikilos changed the title Document equivalent linux commands for ggrep Document equivalent gnu commands for ggrep Aug 22, 2023
@Poikilos Poikilos changed the title Document equivalent gnu commands for ggrep Document equivalent gnu grep commands for ggrep Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant