search for a specific file type with ack

Use –type for this. To only search python files for example: ack –type=python searchthis List all the supported types with ack –help=types # ack 2.x ack –help-types # ack 3.x.x If you want to create a custom type, add something like this to ~/.ackrc: –type-add=custom:ext:rb –type-set Then you can use –type=custom with ack to just … Read more

grep: repetition-operator operand invalid

$ grep -Pio ‘(?<=heads\/)(.*?)(?=\n)’ text.txt # P option instead of E If you use GNU grep, you can use -P or –perl-regexp options. In case you are using OS X, you need to install GNU grep. $ brew install grep Due to recent changes, to use GNU grep on macOS you either have to prepend … Read more

Search for files & file names using silver searcher

According to the man page of ag -G –file-search-regex PATTERN Only search files whose names match PATTERN. You can use the -G option to perform searches on files matching a pattern. So, to answer your question: root@apache107:~/rpm-4.12.0.1# ag -G cpio.c size rpm2cpio.c 21: off_t payload_size; 73: /* Retrieve payload size and compression type. */ 76: … Read more

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

Now that ack 2.0 is available: –ignore-file=ext:orig , either on command line or .ackrc. It is possible to ignore files by name. To ignore ctags generated files: –ignore-file=is:tags Filters for different uses can be found on documentation.

How to let ack support more filetypes?

On window,add .ackrc file under C:\Documents and Settings\yourname,with content –type-set=aspx=.aspx you can set a type to multi file extension,seperate by “,” –type-set=aspx=.aspx,.ascx Note ack syntax and behaviour has changed significantly with version 2. The equivalent of the above in version 2 would be: –type-set=aspx:ext:aspx,ascx Where the syntax is –type-set TYPE:FILTER:FILTERARGS and FILTER can be any … Read more

ack misses results (vs. grep)

ack is peculiar in that it doesn’t have a blacklist of file types to ignore, but rather a whitelist of file types that it will search in. To quote from the man page: With no file selections, ack-grep only searches files of types that it recognizes. If you have a file called foo.wango, and ack-grep … Read more

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

The older versions of ack can only take the folder name, not the folder path. As of version 1.93_02, they’ve added this ability in: 1.93_02 Wed Oct 6 21:39:58 CDT 2010 [ENHANCEMENTS] The –ignore-dir option now can ignore entire paths relative to your current directory. Thanks to Nick Hooey. For example: ack –ignore-dir=t/subsystem/test-data (From betterthangrep.com/Changes) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)