Ack: Usage Cheat Sheet

Usage:

ack [OPTIONS]... PATTERN [FILES OR DIRECTORIES]

Search for PATTERN in each source file in the tree from the current directory on down. If any files or directories are specified, then only those files and directories are checked. ack may also search STDIN, but only if no file or directory arguments are specified, or if one of them is -.

Default switches may be specified in the ACK_OPTIONS environment variable or an .ackrc file. If you want no dependency on the environment, turn it off with --noenv.

Example:

ack -i select

Ack: Searching Cheat Sheet

-i, --ignore-caseIgnore case distinctions in pattern
--[no]smart-caseIgnore case distinctions in pattern, but only if pattern contains no upper caseIgnored if -i is specified.
-v, --invert-matchInvert match: select non-matching lines
-w, --word-regexpForce pattern to match only whole words
-Q, --literalQuote all metacharacters: pattern is literal

Ack: File Presentation Cheat Sheet

--pager=COMMANDPipe all ack output through COMMANDFor example, --pager="less -R". Ignored if output is redirected.
--nopagerDo not send output through a pagerCancels any setting in ~/.ackrc, ACK_PAGER or ACK_PAGER_COLOR.
--[no]headingPrint a filename heading above each file’s resultsThe default is on, when used interactively.
--[no]breakPrint a break between results from different filesThe default is on, when used interactively.
--groupSame as --heading --break
--nogroupSame as --noheading --nobreak
--[no]colorHighlight the matching textThe default is on unless output is redirected, or on Windows.
--color-filename=COLORSet color for filenames
--color-match=COLORSet color for matches
--color-lineno=COLORSet color for line numbers
--[no]colourSame as --[no]color
--flushFlush output immediately, even when ack is used non-interactively (when output goes to a pipe or file)

Ack: File Finding Cheat Sheet

-fOnly print the files selected, without searchingThe PATTERN must not be specified.
-gSame as -f, but only select files matching PATTERN
--sort-filesSort the found files lexically
--show-typesShow which types each file has
--files-from=FILERead the list of files to search from FILE
-xRead the list of files to search from STDIN

Ack: Search Output Cheat Sheet

--lines=NUMOnly print NUM lines of each file
-l, --files-with-matchesOnly print filenames containing matches
-L, --files-without-matchesOnly print filenames with no matches
--output=exprOutput the evaluation of expression for each lineTurns off text highlighting.
-oShow only the part of a line matching pattern
--passthruPrint all lines, whether matching or not
--match PATTERNSpecify pattern explicitly.
-m, --max-count=NUMStop searching in each file after NUM matches
-1Stop searching after one match of any kind
-H, --with-filenamePrint the filename for each matchThis is the default unless explicitly searching a single file.
-h, --no-filenameSuppress the prefixing filename on output
-c, --countShow number of lines matching per file
--[no]columnShow the column number of the first match
-A NUM, --after-context=NUMPrint NUM lines of trailing context after matching lines
-B NUM, --before-context=NUMPrint NUM lines of leading context before matching lines
-C [NUM], --context[=NUM]Print NUM lines of output contextThe default is 2.
--print0Print null byte as separator between filenamesOnly works with -f, -g, -l, -L or -c.
-sSuppress error messages about nonexistent or unreadable files

Ack: File Inclusion and Exclusion Cheat Sheet

--[no]ignore-dir=nameAdd or remove directory from the list of ignored directories
--[no]ignore-directory=nameSynonym for --ignore-dir
--ignore-file=filterAdd filter for ignoring files
-r, -R, --recurseRecurse into subdirectoriesThis is ack’s default behavior.
-n, --no-recurseNo descending into subdirectories
--[no]followFollow symlinksDefault is off.
-k, --known-typesInclude only files with types that ack recognizes
--type=XInclude only files with the filetype X
--type=noXExclude files with the filetype XSee ack --help-types for supported filetypes.

Ack: File Type Specification Cheat Sheet

--type-set TYPE:FILTER:FILTERARGSFiles with the given FILTERARGS applied to the given FILTER are recognized as being of type TYPE. This replaces an existing definition for type TYPE
--type-add TYPE:FILTER:FILTERARGSFiles with the given FILTERARGS applied to the given FILTER are recognized as being of type TYPE
--type-del TYPERemove all filters associated with TYPE

Ack: Miscellaneous Cheat Sheet

--[no]envIgnore environment variables and global ackrc files
--ackrc=filenameSpecify an ackrc file to use
--ignore-ack-defaultsIgnore the default definitions that ack includes
--create-ackrcOutputs a default ackrc for your customization to standard output
--help, -?Display help
--help-typesDisplay all known types
--dumpDump information on which options are loaded from which RC files
--[no]filterForce ack to treat standard input as a pipe (--filter) or tty (--nofilter)
--manMan page
--versionDisplay version and copyright
--thppptBill the Cat
--barThe warning admiral

Ack: File Types Cheat Sheet

--[no]actionscript.as.mxml
--[no]ada.ada.adb.ads
--[no]asm.asm.s
--[no]asp.asp
--[no]aspx.master.ascx.asmx.aspx.svc
--[no]batch.bat.cmd
--[no]cc.c.h.xs
--[no]cfmx.cfc.cfm.cfml
--[no]clojure.clj
--[no]cmakeCMakeLists.txt.cmake
--[no]coffeescript.coffee
--[no]cpp.cpp.cc.cxx.m.hpp.hh.h.hxx
--[no]csharp.cs
--[no]css.css
--[no]dart.dart
--[no]delphi.pas.int.dfm.nfm.dof.dpk.dproj.groupproj.bdsgroup.bdsproj
--[no]elisp.el
--[no]elixir.ex.exs
--[no]erlang.erl.hrl
--[no]fortran.f.f77.f90.f95.f03.for.ftn.fpp
--[no]go.go
--[no]groovy.groovy.gtmpl.gpp.grunit.gradle
--[no]haskell.hs.lhs
--[no]hh.h
--[no]html.htm.html
--[no]java.java.properties
--[no]js.js
--[no]json.json
--[no]jsp.jsp.jspx.jhtm.jhtml
--[no]less.less
--[no]lisp.lisp.lsp
--[no]lua.lua, first line matches /^#!.*\blua(jit)?/
--[no]make.mk.makmakefileMakefileGNUmakefile
--[no]matlab.m
--[no]md.mkd.md
--[no]objc.m.h
--[no]objcpp.mm.h
--[no]ocaml.ml.mli
--[no]parrot.pir.pasm.pmc.ops.pod.pg.tg
--[no]perl.pl.pm.pod.t.psgi, first line matches /^#!.*\bperl/
--[no]perltest.t
--[no]php.php.phpt.php3.php4.php5.phtml, first line matches /^#!.*\bphp/
--[no]plone.pt.cpt.metadata.cpy.py
--[no]pmc.pmc
--[no]python.py, first line matches /^#!.*\bpython/
--[no]rakeRakefile
--[no]rr.R
--[no]ruby.rb.rhtml.rjs.rxml.erb.rake.specRakefile, first line matches /^#!.*\bruby/
--[no]rust.rs
--[no]sass.sass.scss
--[no]scala.scala
--[no]scheme.scm.ss
--[no]shell.sh.bash.csh.tcsh.ksh.zsh.fish, first line matches /^#!.*\b(?:ba|t?c|k|z|fi)?sh\b/
--[no]smalltalk.st
--[no]sql.sql.ctl
--[no]tcl.tcl.itcl.itk
--[no]tex.tex.cls.sty
--[no]textile.textile
--[no]tt.tt.tt2.ttml
--[no]vb.bas.cls.frm.ctl.vb.resx
--[no]verilog.v.vh.sv
--[no]vhdl.vhd.vhdl
--[no]vim.vim
--[no]xml.xml.dtd.xsl.xslt.ent, first line matches /<[?]xml/
--[no]yaml.yaml.yml