1

So I've been trying to use grep to extract some stuff from a Mercurial log and trying to avoid using awk just to see if I can get by without it here, and failing because neither grep nor egrep support full modern regex.

So this happens with grep:

$   hg log <filename> | grep changeset
changeset:   3651:d23495ab1168
changeset:   2974:6aa71cb2c575
changeset:   2756:9dd7fb635678
changeset:   2532:d3ced9af4d6c
changeset:   2459:9d5f5553b851
changeset:   1835:4558836beed1
changeset:   1628:517d0239e830
changeset:   1486:114bce51254d
changeset:   1378:2b968e7fbd19
changeset:   1374:4e7772e48d00

This is what I want in terms of output results. But to get better regex support, I tried doing this with ack, aaaand....nothing. What am I missing? Checked a bunch of examples and can see no difference in what I'm doing here.

$  hg log <filename> | ack changeset
$ 

There is no output.

Maybe I am misunderstanding this tool? egrep did not have enough support either. I just want to use \s :(

  • 1
    What version of ack do you have? You example works fine for me with version 2.14. – Stephen Kitt Apr 16 '15 at 22:45
  • 1
    Huh, 1.39. Weird, I just sudo apt-get'd it....why am I out of date... – temporary_user_name Apr 16 '15 at 22:50
  • What distribution are you using? Even Debian oldstable has 1.92... – Stephen Kitt Apr 16 '15 at 22:54
  • Ubuntu 12.04. Trying to install from this and it is not going well, can't find an actual download link. – temporary_user_name Apr 16 '15 at 22:57
  • Try downloading it from Ubuntu instead... – Stephen Kitt Apr 16 '15 at 23:00
0

Saw this on the ack documentation page, maybe it would help?

 --[no]filter                  Force ack to treat standard input as a pipe
                            (--filter) or tty (--nofilter)
  • Unfortunately that (bizarrely) just caused ack to inform me of its version info and basic usage. – temporary_user_name Apr 16 '15 at 22:40
  • sorry that didn't work. – FrankRalphBob Apr 16 '15 at 22:49
0

try entering

awk '/changeset/ {print}'
  • That only partially works and raises a host of new questions. As you wrote it, it produces the same output as above. But when I adjust the pattern to be /\s\d+(?=:)/ (digits followed by a colon and preceded by whitespace) which should match all the same lines, then it gives zero output. Moreover, why can I just write {print} rather than {print(something);} ? – temporary_user_name Apr 16 '15 at 22:46
-1

ack is a default package installed on Debian based distributions. If you see a message like this when you run ack -h then you need to use ack-grep or follow the step at http://beyondgrep.com/install/ on Renaming ack-grep on Debian-derived distros

Try hg log <filename> | ack-grep changeset to see if ack-grep is installed properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.