Re: [dev] show line number *and* column number in a search

From: Κράκ Άουτ <krackout_AT_gmx.com>
Date: Mon, 20 Jun 2022 16:44:39 +0300

Στις 20 Ιουν 2022 16:02, ο/η Greg Reagle έγραψε:
> On Mon, Jun 20, 2022, at 3:00 AM, mb_AT_datameer.com wrote:
>> "Greg Reagle" <list_AT_speedpost.net> wrote:
>>> ls | awk '/er.*/ {match($0, /er.*/); print $0; print NR":"RSTART"-"RSTART+RLENGTH}'
>>> debfoster-a-notes.txt
>>> 3:8-22
>>> vdirsyncer
>>> 21:9-11
>>>
>>> So there is a match on line 3 columns 8-22 and line 21 columns 9-11. Exactly what I want. I am curious though, is there a "better" way? A version of grep that has a column number option? Are just a simpler way of achieving this goal?
>>
>> I'm using ag[0]. Does that fit your needs?
>>
>> [0] https://geoff.greer.fm/ag/
>
> I tried the related program ack because it was easy for me to install (I don't see a Debian stable package for ag), and it does produce a starting column number. Thank you for the suggestion!
>
> ls | ack -H --column 'er.*'
> -
> 3:8:debfoster-a-notes.txt
> 20:9:vdirsyncer
>

In case you want to try it, `ag` is `silversearcher-ag` package in Debian.
Received on Mon Jun 20 2022 - 15:44:39 CEST

This archive was generated by hypermail 2.3.0 : Mon Jun 20 2022 - 16:00:09 CEST