Questions tagged [ack]

ack is a tool like grep, designed for programmers with large trees of heterogeneous source code.

ack is a tool like grep, designed for programmers with large trees of heterogeneous source code. http://beyondgrep.com

262 questions
123
votes
10 answers

How to truncate long matching lines returned by grep or ack

I want to run ack or grep on HTML files that often have very long lines. I don't want to see very long lines that wrap repeatedly. But I do want to see just that portion of a long line that surrounds a string that matches the regular expression. How…
dan
  • 43,914
  • 47
  • 153
  • 254
77
votes
1 answer

Ignoring a directory using ack's .ackrc

I'm not sure what it's for, but the code I'm working on has a bunch of folders called "save.d," it looks like they're used for some sort of version control (we also have .svn folders). How can I update my .ackrc file to ignore those directories by…
Parris Varney
  • 11,320
  • 12
  • 47
  • 76
74
votes
9 answers

How can I install and use ack library on Windows?

I have never used Perl, but I am really impressed by the ack, which I would like to use for source code searching, etc. Can anyone guide me of how to make use of this excellent library on Windows?
rajesh pillai
  • 8,102
  • 7
  • 43
  • 60
63
votes
5 answers

How do you exclude a specific file from ack (ack-grep)?

With the normal grep command there is an --exclude option (covered in detail here: Use grep --exclude/--include syntax to not grep through certain files) that lets you ignore specific files when you are grepping. Ack's --type option takes care of…
machineghost
  • 33,529
  • 30
  • 159
  • 234
60
votes
5 answers

How to do search & replace with ack in vim?

I am using the Ack plugin in Vim, which helps me to quickly search for strings in my project. However, sometimes I want to replace all or some occurrences of the found strings. You can do some kind of global search and replace using the Vim arglist…
Ralph von der Heyden
  • 1,715
  • 1
  • 15
  • 15
55
votes
2 answers

ack: Excluding only one directory but keeping all others with the same name

My folder structure looks like this: /app /app/data ... /app/secondary /app/secondary/data I want to recursively search /app, including /app/data. I do not want to search /app/secondary/data however. This what I have so far: ack --ignore-dir=data…
mattalxndr
  • 9,143
  • 8
  • 56
  • 87
46
votes
4 answers

ack misses results (vs. grep)

I'm sure I'm misunderstanding something about ack's file/directory ignore defaults, but perhaps somebody could shed some light on this for me: mbuck$ grep logout -R app/views/ Binary file app/views/shared/._header.html.erb.bak.swp matches Binary…
techpeace
  • 2,606
  • 1
  • 22
  • 21
45
votes
2 answers

How to let ack support more filetypes?

in ack's home page, there lists a lot of file type, but without aspx, is it possible to let ack support it?
prime23
  • 3,362
  • 2
  • 36
  • 52
39
votes
4 answers

Ack — Ignoring multiple directories without repeating the flag

Is it possible to ignore multiple directories in Ack, without repeating the flag? e.g. I know the following works (i.e. setting multiple flags): ack --ignore-dir=install --ignore-dir=php 'teststring' I was hoping that I could separate directories…
SparrwHawk
  • 13,581
  • 22
  • 61
  • 91
38
votes
1 answer

ack regex: Matching two words in order in the same line

I would like to find lines in files that include two words, word_1 and word_2 in order, such as in Line A below, but not as in Line B or Line C: Line A: ... word_1 .... word_2 .... Line B: ... word_1 .... Line C: ... word_2 .... I have tried $ack…
Amelio Vazquez-Reina
  • 91,494
  • 132
  • 359
  • 564
38
votes
4 answers

How can I get ack to ignore *.orig files?

I put this in my .ackrc: --type-set=DUMB=*.orig --noDUMB ... but I'm still seeing files like main.py.orig in my ack results. I tried doing --type-set=DUMB=*.*.orig too, but that didn't work either. More info Run from my command line (OSX Snow…
timmfin
  • 2,025
  • 1
  • 15
  • 14
31
votes
3 answers

search for a specific file type with ack

How can I use ack to search in files of a specific file type. For example ack -f .scss blah acl -f .rb blah Obviously the above does not work but how can I do this with ack?
dagda1
  • 26,856
  • 59
  • 237
  • 450
31
votes
6 answers

Search for files & file names using silver searcher

Using Silver Searcher, how can I search for: (non-binary) files with a word or pattern AND all filenames, with a word or pattern including filenames of binary files. Other preferences: would like to have case insensitive search and search through…
Jikku Jose
  • 18,306
  • 11
  • 41
  • 61
29
votes
5 answers

Can ack find files based on filename only?

Using ack (sometimes packaged as ack-grep) I know that I can find paths that contain a specific string by doing: ack -g somestring But what if I only want files which have "somestring" in their filenames?
Suan
  • 34,563
  • 13
  • 47
  • 61
29
votes
3 answers

grep: repetition-operator operand invalid

I have this regular express (?<=heads\/)(.*?)(?=\n) and you can see it working here http://regexr.com?347dm I need this regex to work in the grep command but I'm getting this error. $ grep -Eio '(?<=heads\/)(.*?)(?=\n)' text.txt grep:…
jspooner
  • 10,975
  • 11
  • 58
  • 81
1
2 3
17 18