Results 1 to 6 of 6
Hi all,
I am working on a code base which has lot of source code files. So, i end up using ack ( ack 1.94 -- better than grep, a ...
- 02-07-2011 #1Just Joined!
- Join Date
- Feb 2009
- Location
- Chennai, India
- Posts
- 28
How to tell ack tool to ignore case under REGEX
Hi all,
I am working on a code base which has lot of source code files. So, i end up using ack (ack 1.94 -- better than grep, a source code search tool for programmers) tool for searching the filename i need to open.
My source code is arranged in the following manner
/home
/home/X/sample.c
/home/X/Sample.c
/home/X/sAmPle.c
...
...
...
Now i need to list the files whose name is "sample" ignoring the case. When i look at the man page of ACK command i can see that ignore case can't be used with -g option.
I am not comfortable with REGEX. Can some one help me in forming the REGEX so that i can list all the files with name "sample" regardless of case.-g REGEX
Print files where the relative path + filename matches REGEX. This option is a convenience shortcut for -f -G REGEX.
The options -i, -w, -v, and -Q do not apply to this REGEX.
Thanks.
- 02-07-2011 #2
if it is true regex, you could do
[sS][aA][mM][pP][lL][eE]\.[cC]
but I haven't used that tool, so I can't confirm.New to the internet, technical forums, or the hacker / open source community??
Read this to learn good posting habits http://www.catb.org/~esr/faqs/smart-questions.html
RHCE for RHEL version 5
RHCT for RHEL version 4
- 02-08-2011 #3Just Joined!
- Join Date
- Jul 2008
- Posts
- 81
Reading the man.page for ack I find the following switch:
-i, --ignore-case Ignore case distinctions in PATTERN
This ought to solve your problem without needing a REGEX.
Try the command:
ack -i sample.c
- 02-17-2011 #4Just Joined!
- Join Date
- Feb 2009
- Location
- Chennai, India
- Posts
- 28
@meton: Thanks your solution works
@clowenstein: I have already looked into man page and it was clearly mentioned ignore case can't be used with -g option
Extract from man page
-g REGEX
Print files where the relative path + filename matches REGEX. This option is a convenience shortcut for -f -G REGEX.
The options -i, -w, -v, and -Q do not apply to this REGEX.
- 02-17-2011 #5Just Joined!
- Join Date
- Jul 2008
- Posts
- 81
My point was that for the example you gave, you don't need to use a REGEX at all.
If your real problem is more complicated than that simple example, perhaps you need to state it better.
- 02-21-2011 #6New to the internet, technical forums, or the hacker / open source community??
Read this to learn good posting habits http://www.catb.org/~esr/faqs/smart-questions.html
RHCE for RHEL version 5
RHCT for RHEL version 4


Reply With Quote

