ack – grep 확장 프로그램
Beyond grep 으로 알려진 ack는 우리에게 친숙한 grep 의 확장 프로그램이다. ( http://beyondgrep.com/ )
grep 과 ack 의 차이점
- grep 에서는 -r 옵션을 선언해야 하위폴더까지 체크하지만 ack 는 -r 옵션을 기본적으로 포함하고 있어서 따로 옵션을 하지 않아도 된다.
- grep 에서는 -n 옵션을 선언해야 몇 라인인지 표시하지만 ack 는 -n 옵션을 포함하고 있어 따로 옵션하지 않아도 된다.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
[root@server ~]# yum install ack Loaded plugins: fastestmirror, security Setting up Install Process Loading mirror speeds from cached hostfile * base: ftp.daumkakao.com * epel: mirror.premi.st * extras: ftp.daumkakao.com * updates: ftp.daumkakao.com Resolving Dependencies --> Running transaction check ---> Package ack.noarch 0:2.12-2.el6 will be installed --> Processing Dependency: perl(File::Next) >= 1.10 for package: ack-2.12-2.el6.noarch --> Running transaction check ---> Package perl-File-Next.noarch 0:1.12-1.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================= Package Arch Version Repository Size ======================================================================================= Installing: ack noarch 2.12-2.el6 epel 70 k Installing for dependencies: perl-File-Next noarch 1.12-1.el6 epel 19 k Transaction Summary ======================================================================================= Install 2 Package(s) Total download size: 90 k Installed size: 195 k Is this ok [y/N]: y Downloading Packages: (1/2): ack-2.12-2.el6.noarch.rpm | 70 kB 00:00 (2/2): perl-File-Next-1.12-1.el6.noarch.rpm | 19 kB 00:00 ---------------------------------------------------------------------------------------- Total 338 kB/s | 90 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : perl-File-Next-1.12-1.el6.noarch 1/2 Installing : ack-2.12-2.el6.noarch 2/2 Verifying : perl-File-Next-1.12-1.el6.noarch 1/2 Verifying : ack-2.12-2.el6.noarch 2/2 Installed: ack.noarch 0:2.12-2.el6 Dependency Installed: perl-File-Next.noarch 0:1.12-1.el6 Complete! |
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
[root@server ~]# ack --help Usage: ack [OPTION]... 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 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 Searching: -i, --ignore-case Ignore case distinctions in PATTERN --[no]smart-case Ignore case distinctions in PATTERN, only if PATTERN contains no upper case. Ignored if -i is specified -v, --invert-match Invert match: select non-matching lines -w, --word-regexp Force PATTERN to match only whole words -Q, --literal Quote all metacharacters; PATTERN is literal Search output: --lines=NUM Only print line(s) NUM of each file -l, --files-with-matches Only print filenames containing matches -L, --files-without-matches Only print filenames with no matches --output=expr Output the evaluation of expr for each line (turns off text highlighting) -o Show only the part of a line matching PATTERN Same as --output='$&' --passthru Print all lines, whether matching or not --match PATTERN Specify PATTERN explicitly. -m, --max-count=NUM Stop searching in each file after NUM matches -1 Stop searching after one match of any kind -H, --with-filename Print the filename for each match (default: on unless explicitly searching a single file) -h, --no-filename Suppress the prefixing filename on output -c, --count Show number of lines matching per file --[no]column Show the column number of the first match -A NUM, --after-context=NUM Print NUM lines of trailing context after matching lines. -B NUM, --before-context=NUM Print NUM lines of leading context before matching lines. -C [NUM], --context[=NUM] Print NUM lines (default 2) of output context. --print0 Print null byte as separator between filenames, only works with -f, -g, -l, -L or -c. -s Suppress error messages about nonexistent or unreadable files. File presentation: --pager=COMMAND Pipes all ack output through COMMAND. For example, --pager="less -R". Ignored if output is redirected. --nopager Do not send output through a pager. Cancels any setting in ~/.ackrc, ACK_PAGER or ACK_PAGER_COLOR. --[no]heading Print a filename heading above each file's results. (default: on when used interactively) --[no]break Print a break between results from different files. (default: on when used interactively) --group Same as --heading --break --nogroup Same as --noheading --nobreak --[no]color Highlight the matching text (default: on unless output is redirected, or on Windows) --[no]colour Same as --[no]color --color-filename=COLOR --color-match=COLOR --color-lineno=COLOR Set the color for filenames, matches, and line numbers. --flush Flush output immediately, even when ack is used non-interactively (when output goes to a pipe or file). File finding: -f Only print the files selected, without searching. The PATTERN must not be specified. -g Same as -f, but only select files matching PATTERN. --sort-files Sort the found files lexically. --show-types Show which types each file has. --files-from=FILE Read the list of files to search from FILE. -x Read the list of files to search from STDIN. File inclusion/exclusion: --[no]ignore-dir=name Add/remove directory from list of ignored dirs --[no]ignore-directory=name Synonym for ignore-dir --ignore-file=filter Add filter for ignoring files -r, -R, --recurse Recurse into subdirectories (default: on) -n, --no-recurse No descending into subdirectories --[no]follow Follow symlinks. Default is off. -k, --known-types Include only files of types that ack recognizes. --type=X Include only X files, where X is a recognized filetype. --type=noX Exclude X files. See "ack --help-types" for supported filetypes. File type specification: --type-set TYPE:FILTER:FILTERARGS Files 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:FILTERARGS Files with the given FILTERARGS applied to the given FILTER are recognized as being type TYPE. --type-del TYPE Removes all filters associated with TYPE. Miscellaneous: --[no]env Ignore environment variables and global ackrc files. --env is legal but redundant. --ackrc=filename Specify an ackrc file to use --ignore-ack-defaults Ignore default definitions included with ack. --create-ackrc Outputs a default ackrc for your customization to standard output. --help, -? This help --help-types Display all known types --dump Dump information on which options are loaded from which RC files --[no]filter Force ack to treat standard input as a pipe (--filter) or tty (--nofilter) --man Man page --version Display version & copyright --thpppt Bill the Cat --bar The warning admiral --cathy Chocolate! Chocolate! Chocolate! |