ack3 icon indicating copy to clipboard operation
ack3 copied to clipboard

Request: --no-group-separator option

Open hftf opened this issue 2 years ago • 4 comments

Ack, grep, and other programs sensibly print -- between groups of context (-A/-B/-C). However, it would be nice to disable the -- with an option especially when the output will be further processed. GNU grep has a --no-group-separator option for this.

See also https://stackoverflow.com/questions/2168065/how-do-i-get-rid-of-line-separator-when-using-grep-with-context-lines.

hftf avatar Oct 11 '22 17:10 hftf

Seems useful. First thing that comes to mind is that we may have confusing with --group/--nogroup. I'm not saying that's a show-stopper.

Please tell me about how you would use this.

petdance avatar Oct 11 '22 17:10 petdance

For an example, I have a log of stenography keystrokes pressed (one stroke per line) and use the -A/-B/-C context feature to get all strokes before or after an undo stroke, so I can see which words I commonly mistype and what are the misstrokes I write instead. Further processing of the output is done to extract the words from within the log's line format, sort, tally, etc. I don't need the group separators during further processing, although it doesn't get in the way too badly.

hftf avatar Oct 11 '22 19:10 hftf

@petdance says

Please tell me about how you would use this.

space-track.org publishes satellite orbital elements (3 lines per satellite - first line is the name, and the 2nd and 3rd lines are the data). I use ack with -A 2 as a filter to select satellites by name.

I really don't want the -- in the output - it breaks my downstream applications.

Here is the documentation of the format: https://www.space-track.org/documentation#tle-basic

Would appreciate it if you were to add this --no-group-separator option.

As a workaround I'm just using Gnu grep for this step.

glanois avatar Nov 24 '23 05:11 glanois

As a workaround I'm just using Gnu grep for this step.

That doesn't sound like a workaround. It sounds like using the right tool for the job.

If the use case is a pipeline, and grep works, I'd suggest using grep. ack is geared towards being read by humans on a screen.

petdance avatar Nov 26 '23 17:11 petdance