Suche in Dateien unter Linux mit ack-grep

Aus Thomas-Krenn-Wiki
Zur Navigation springen Zur Suche springen

Das Tool ack-grep eignet sich unter Linux zum Suchen innerhalb von Dateien auf der Kommandozeile. In diesem Artikel finden Sie einige Informationen wie Sie ack-grep verwenden können.

Installation

Unter Ubuntu installieren Sie ack-grep mit folgendem Kommando:

sudo apt-get install ack-grep

Suche nach Dateiinhalten

Mit folgendem Aufruf suchen Sie nach dem angeführten Suchbegriff in allen Dateien des lokalen Verzeichnisses und aller Unterverzeichnisse. Groß-/Kleinschreibung wird dabei nicht berücksichtigt (-i Parameter):

ack-grep -i "suchbegriff"

Unterstützte Dateitypen

Mit folgendem Aufruf zeigt ack-grep alle unterstützten Dateiformate:

ack-grep --help=types

Das folgende Beispiel zeigt die Ausgabe unter Ubuntu 14.04:

admin@ubuntu-1404:~$ ack-grep --help=types
Usage: ack-grep [OPTION]... PATTERN [FILES OR DIRECTORIES]

The following is the list of filetypes supported by ack-grep.  You can
specify a file type with the --type=TYPE format, or the --TYPE
format.  For example, both --type=perl and --perl work.

Note that some extensions may appear in multiple types.  For example,
.pod files are both Perl and Parrot.

    --[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]cmake        CMakeLists.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; .mak; makefile; Makefile; GNUmakefile
    --[no]matlab       .m
    --[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]python       .py; first line matches /^#!.*\bpython/
    --[no]rake         Rakefile
    --[no]rr           .R
    --[no]ruby         .rb .rhtml .rjs .rxml .erb .rake .spec; Rakefile; 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]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

Weitere Informationen


Foto Werner Fischer.jpg

Autor: Werner Fischer

Werner Fischer arbeitet im Product Management Team von Thomas-Krenn. Er evaluiert dabei neueste Technologien und teilt sein Wissen in Fachartikeln, bei Konferenzen und im Thomas-Krenn Wiki. Bereits 2005 - ein Jahr nach seinem Abschluss des Studiums zu Computer- und Mediensicherheit an der FH Hagenberg - heuerte er beim bayerischen Server-Hersteller an. Als Öffi-Fan nutzt er gerne Bus & Bahn und genießt seinen morgendlichen Spaziergang ins Büro.


Das könnte Sie auch interessieren

Intel Management Engine Interface mei Linux Treiber
LoRaWAN Transceiver in The Things Stack (TTS) einbinden
PCIe Bus Error Status 00001100 beheben