Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9223311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:03:02+00:00 2026-06-18T04:03:02+00:00

Oddness in ack (betterthangrep.com) – Sometimes I get a line number, sometimes not. In

  • 0

Oddness in ack (betterthangrep.com) – Sometimes I get a line number, sometimes not.

In the first example, I look for a simple phrase in some Python files.
It works fine, and shows line number 233.
In the second example, I look for all lines where the first column ends with ‘5’.

D:\DSWProj\2012L\src> perl D:\ack-standalone.pl  "return True"  *.py
Volume5.py
233:    return True


D:\DSWProj\2012L\data\R123> perl D:\ack-standalone.pl  "5 "  NeedMoreCoffee_n5_*.data
Volume5 FooData  coffee_n5  2013-01-29 10:14
 397125 0 0 1 0
 397135 0 0 1 0

Those two lines are exactly the first two lines in the file following the header line.

Why are there no line numbers in this second example? There’s also no file name printed, and no colorization. The Python example does colorize output – the line numbers are yellow, file names green. (A surprise, since the last time I asked, was told Windows command line shell can’t colorize anything at all.) Is this a bug in ack, or quirk of Windows? Did I do something unwittingly different between the two cases, besides the obvious searching for different things in different files?

Running on Windows 7 64-bit, using Strawberry Perl 5.16.2 downloaded two days ago (January 28th, 2013),
and ack standalone script, ver 1.96, downloaded also two days ago.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:03:03+00:00Added an answer on June 18, 2026 at 4:03 am

    I believe ack magically* knows that *.py files are Python source code, and will show line numbers and colorization for source code files but not for plain old data files like *.data. This is considered a feature, not a bug.

    If you want a predictable, composable replacement for grep, try grep. 😉

    * – It’s not really magic, of course; it’s configurable in your .ackrc file. Run ack --help-types for more information.

    EDIT: I’m wrong! It’s not because of the difference between .py and .data; it’s because of the difference between ack pattern f1 and ack pattern f1 f2 .... In the latter case, ack will print which of the files f1 f2 ... contained the matches; in the former (single file) case, ack will behave more like grep.

    To fool ack into producing line numbers even for a single file, add a fake file on the end of the line. For Cygwin, you could probably do

    perl D:\ack-standalone.pl  "5 "  NeedMoreCoffee_n5_*.data /dev/null
    

    For Windows, maybe this still works:

    perl D:\ack-standalone.pl  "5 "  NeedMoreCoffee_n5_*.data NUL
    

    (that’s literally the letters N U L, which is how Windows spells /dev/null; see also CON, LPT1, etc).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get to the bottom of some oddness between doing AJAX with
Here's a sample of some oddness: #!/usr/bin/ruby require 'rubygems' require 'open-uri' require 'nokogiri' print
I am having trouble fabricating a Regex which will returns tags that are not
I've been looking for some simple coding challenges recently, and discovered about Pascal's triangle
Bit of oddness, seen if I do the following: import javax.swing.*; public class FunkyButtonLayout
I have a C++ command line program compiled with Microsoft Visual Studio 2003, and
I've had a good look around and I think I'm close, but I'm really
When I try to get a month before last from today, I run date
This is a bit difficult to explain, so please bear with me. I am
How Many Times Does an ASP .NET Application Start? I want to run something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.